FileNotFoundException

Answered

 I put a .txt file in resources folder in plugin I'm working on and I can't get a handle on it

Txt file is in resources folder, using tool_window run configuration to test code, added .txt to resource pattern, file still not found

Note: absolute path is working, relative isn't

Scanner s = new Scanner(new BufferedReader(new FileReader("keywords.txt")));

java.io.FileNotFoundException: keywords.txt (The system cannot find the file specified)

2 comments
Comment actions Permalink

Please Google for: "java read resource from classpath".

0
Comment actions Permalink

Ty, I used:

URL file = this.getClass().getResource("keywords.txt");
Scanner s = new Scanner(new File(file.getFile()));

Probably a better way to do this but whatever.
0

Please sign in to leave a comment.