FileNotFoundException Issue
I have a program that needs to read another file while running. When I run the program I get a FileNotFoundException thrown back. I have placed a copy of the file needing to be read, "balls.nff", within the classes folder of my compiled program (also my CLASSPATH). Also, I have set proper file permissions (read, write) to this file. Do I have my file "balls.nff" in the right directory. How come it can't find it? Where is it looking for it? Can anyone help?
The relative portion of the source code is as follows:
staticvoid ReadFile(String file)
{
try{
if (file ==null)
file ="balls.nff";
FileInputStream s =new FileInputStream(file);
StreamTokenizer d =new StreamTokenizer(new InputStreamReader(s));
d.commentChar('#');
int t;
while (d.nextToken() != StreamTokenizer.TT_EOF)
{
ReadDescriptor(d);
}
}catch (Exception e){
System.out.println ("ReadFile Error: " + e);
e.printStackTrace();
System.exit(1);
}
}
After compiling and running the program I get the following:
ReadFile Error: java.io.FileNotFoundException: balls.nff (No such file or directory)
java.io.FileNotFoundException : balls.nff (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>( FileInputStream.java:66)
at Raytracer_class_impl.ReadFile(\Raytracer_class_impl.java)
at Raytracer_class_impl.main(\Raytracer_class_impl.java)
at Raytracer_class_impl_KStub.main(Raytracer_class_impl_KStub.java)
at Raytracer.main(\Raytracer.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at jp.lang.JavaParty.invokeMain(JavaParty.java:207)
at jp.lang.JavaParty.mainExec(JavaParty.java:177)
at jp.lang.JavaParty.main(JavaParty.java:139)

