The following code is from a method in a class that I am making to modify a list of file directories in a program folder. However I am trying to use "\" as a delimiter for a scanner as I only need the start of the directory "S:\" and the last part which is just name of a sub folder. So for example it looks like this:
F:\Data\Subfolder\Another
The code complies but when I run the method i get this following run time error:
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \
And was just wondering if anyone knows what it means and how I can stop it from happening. Is it because of using the \ for a delimeter?
Note: newFolder class is a nested class
public void scanFiles() throws IOException{
try
{
System.out.println("Sage 2015 is Installed on this machine");
File companyFile = new File(sageFolders[8] + "\\COMPANY");
Scanner input = new Scanner(new BufferedReader(new FileReader(companyFile)));
input.useDelimiter("\\");
while(input.hasNextLine())
{
if(line.contains("F"))
{
String drive = input.next();
String dataFolder = input.next();
String sageFolder = input.next();
String clientFolder = input.next();
newFolders.add(new newFolder(drive, clientFolder));
}
}
//Close the Readers
fileReader.close();
bufferedReader.close();
//fileWriter = new FileWriter(companyFile);
//bufferedWriter = new BufferedWriter(fileWriter);
//Write back to file
//fileWriter.flush();
//bufferedWriter.close();
}
catch(FileNotFoundException e)
{
System.out.println("File not Found: Moving onto next Version");
}
}
class newFolder
{
private String driveLetter;
private String clientFolder;
public newFolder(String driveLetter, String clientFolder)
{
this.driveLetter = driveLetter;
this.clientFolder = clientFolder;
}
}