Could you please help me find a solution for this problem?
I am trying to make a java GUI with Swing components
The interface is supposed to accept a Windows path to a certain file and trigger a set of function on the file after pressing the submit button
Right now I have created the component to get the user input as:
JTextField introducedPath1 = new JTextField(50);
I tried to change the default Windows path obtained by copy pasting the path from explorer into an accepted File path:
File file;
String makeCanonicalPath=introducedPath1.getText().toString();
makeCanonicalPath=makeCanonicalPath.replaceAll("\\", "/");
file = new File(makeCanonicalPath);
But I keep getting this error:
Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
Which I assume it is caused by the default path in windows(ex:L:\practice\test) getting its '\' interpreted as escape sequences.
Any help or suggestion will be appreciated