ARACK04
asked on
file not found exception
FileInputStream toZip = new FileInputStream("dir\\" + (String)filenames.elementA t(i));
generates exception:
java.io.FileNotFoundExcept ion: dir\2.txt (The system cannot find the path specified)
I used a relative path, and from where (both) the .java and .class files are, there is a directory named dir with a file named 2.txt in it. Any ideas?
Thanks!
generates exception:
java.io.FileNotFoundExcept
I used a relative path, and from where (both) the .java and .class files are, there is a directory named dir with a file named 2.txt in it. Any ideas?
Thanks!
It is relative from where you run it
to have it relative to class file try:
InputStream toZip = getClass().getResourceAsSt ream("dir/ " + (String)filenames.elementA t(i));
InputStream toZip = getClass().getResourceAsSt
ASKER
When you say it's relative from where I run it, is that the location of java.exe?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.