Reputation: 901
The URL below is null, and a null pointer is resulted at "toURI()".
URL u = getClass().getClassLoader().getResource("res/root.txt");
File f = new File(u.toURI());
Scanner sc = new Scanner(f);
I've looked in out/production/MyProject/res and the .txt file is not there. I've tried rebuilding and compiling the project, but nothing so far has made IntelliJ think the .txt file is required. >_>
I've also tried having a look at preferences, though I'm not sure what I'm looking for, the compiler doesn't have anything set to be ignored so I don't know.
Any ideas?
P.S. my operating system is Mac OSX if that helps
Upvotes: 1
Views: 1622
Reputation: 559
In IDEA, Project Settings > Compiler lists resource patterns corresponding to files that will be copied to the compile output path.
By default, files with the .txt extension are not included, so you will simply need to add the corresponding pattern to that list for your project.
Upvotes: 8