Is the value of the variable: is null?
Print out the value of path to see what file it is looking for and check if that file exists.
Are the files on the classpath?
Check the API doc for the method getResourceAsStream
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
I don't think you can use getResource... for things outside the jar/classpath (hopefully someone will correct me if I'm wrong...).
However, this little snippet from deep in my old code box will give you a File reference to the jar that the class in which you execute this code came from...
File jarFile = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
then from that File object you can extract the containing directory (getParentFile()) and use that to make the full path to your text files
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Yeah, I can't remember now where I found the getProtectionDomain bit - that's the most non-obvious thing, but I always stash stuff like that away in case it comes in useful later. I use it to display the jar file creation date when there are problems - a kind of automatic version number check.
Let me know when you get the whole thing working?
Cheers
J
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Mark this thread "solved" so people know there's a solution here.
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073