I'm reading in a file, the problem is that I can read anything in my own directory, and anything in any sub-directories, however when I use .getPath()
It gives me the full path from route e.g. C:\Users\smandre\Documents\file.txt
. How can I use this path to read in a file from my program? I've also tried `.getCanonicalPath()
int returnVal = c.showOpenDialog(c);
if(returnVal == JFileChooser.APPROVE_OPTION) {
setFilePath(c.getSelectedFile().getPath());
try {
br = new BufferedReader(new FileReader(getFilePath()));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("You chose to open this file: " + c.getSelectedFile().getPath());
// System.out.println(ClassLoader.getSystemResourceAsStream(getFilePath()));
return;
}
Obviously the above is trying to open the file path starting from my system route, not from my current directory...