Hi,
The title might not be entirely clear, but I'll try to explain.
I'm trying to access a file with a path like /net/blm50+hmm/synlist/
, which works fine when I don't export to a jar file and just run it from within my IDE (eclipse). However, if I try to run it when I have exported it, I get a null pointer exception. It runs without a problem if I rename the path to not have the plus sign in it. Can I escape the plus sign or something like that?
You might ask why I don't just rename the folder, and the reason for this is laziness. There is ALOT of folders to rename and I'd rather avoid it.
I hope You can help,
shalmon
EDIT:
I have a class FileUtils I use for accessing resources in the application jar:
public class FileUtils {
public static InputStream getInputStreamForResource(String resourcePath) throws IOException {
// Try to get the file from the application jar first.
InputStream result = FileUtils.class.getResourceAsStream(resourcePath);
return result;
}
public static Scanner getScanner(String resourcePath) throws IOException {
return new Scanner(getInputStreamForResource(resourcePath));
}
}
If I call getScanner("/net/blm50+hmm/synlist/");
I get the null pointer exception.
The stacktrace is (the call to getScanner happens in NetworkCollection.fromSynapseList):
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
at java.util.Scanner.<init>(Scanner.java:590)
at persistence.FileUtils.getScanner(FileUtils.java:34)
at calculation.NetworkCollection.fromSynapseList(NetworkCollection.java:89)
at processes.JobDispatcher.doInBackground(JobDispatcher.java:136)
at processes.JobDispatcher.doInBackground(JobDispatcher.java:1)
at javax.swing.SwingWorker$1.call(SwingWorker.java:277)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at javax.swing.SwingWorker.run(SwingWorker.java:316)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)