- I'm working on a Java program in Netbeans that I'd like to be able to run from an external jar file
- And I cannot seem to read from a file that isn't located inside of the project default directory or some subfolder located there, and that only works inside Net beans.
- What I'd like to be able to do is read the text file from the file path
src/assets/files/textFile.txt
.
I've tried all of the suggestions here, but they don't seem to work for me. Here's the code I'm currently using:
File file = new File("assets/files/textFile.txt");
if (!file.exists()) {
throw new FileNotFoundException("File does not exist");
}
FileReader fr = new FileReader(file.getAbsoluteFile());
BufferedReader br = new BufferedReader(fr);
When I try to run this, the exception is thrown each time.