FileNotFoundException

已回答

 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)

0

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

0

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

请先登录再写评论。