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"))); keywords.txt (The system cannot find the file specified)

Comment actions Permalink

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

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.

Please sign in to leave a comment.