String line = "Extracting from E:\\Junk\\morejunk\\file.txt";
System.out.println(line); //prints: Extracting from E:\Junk\morejunk\file.txt
String[] splitPath = line.split("\\"); //exception thrown here
String folder = splitPath[splitPath.length-2];
System.out.println(folder);
Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
My objective is to always print the folder containing the file being extracted (morejunk in this case).
Any suggestions why it wont accept "\\" as a pattern which is correctly syntaxed?