Reputation: 23
In my Java project in netbeans I get a text files contents to populate some internal data structure using this:
InputStream PFile = this.getClass().getResourceAsStream("../../IISP Details/IISP.txt"); // Get File to create IISP's
String[] PStringArray = new Scanner(PFile, "UTF-8").useDelimiter("\\A").next().split("\\r?\\n");
But when I clean and build my project it isn't working.
Ideas?
Edit:
More info...
The code is called in the cs.analyser.gui.master package in the 'loadMaster' class.
The file is in cs.analyser.IISPDetails.
I can tell that it's not finding the file - are there any alternatives? Or anyways to make the file get bundled with it when I build it?
Upvotes: 0
Views: 80
Reputation: 8338
Try this
InputStream PFile = this.getClass().getResourceAsStream("IISP.txt"); // Get File to create IISP's
String[] PStringArray = new Scanner(PFile, "UTF-8").useDelimiter("\\A").next().split("\\r?\\n");
and add the IISP.txt to a location that it is in the CLASSPATH.
Don't know about classpath? http://docs.oracle.com/javase/tutorial/essential/environment/paths.html
Upvotes: 1