0

I have done this:

File inputPropertiesFile = new File("/Users/adrian/Documents/workspace/Ronan/src/watermarker/test");
InputStream propertiesStream = new FileInputStream(inputPropertiesFile);

but I get this exception:

java.io.FileNotFoundException: /Users/adrian/Documents/workspace/Ronan/src/watermarker/test (No such file or directory)     at java.io.FileInputStream.open(Native Method)  at java.io.FileInputStream.<init>(FileInputStream.java:120)     

But the file is at that location fooor suure.And is not empty.What is wrong there?

Thank you

adrian
  • 4,514
  • 17
  • 67
  • 118

5 Answers5

1

Maybe you can check if the File is accessible for the Program?

If the File is not accessible, it also cannot be found and hence raises this exception.

Max
  • 991
  • 1
  • 10
  • 25
1

Yeah, if you try using /Users/adrian in explorer, you won't get to that path. If you use C:/Users/adrian, you will. I'm sure java is having the same problem

sindrem
  • 1,161
  • 5
  • 23
  • 42
0

surround it by a try-catch block

try {
        inputStream = new FileInputStream(propertiesFile);
        prop.load(inputStream);
    } catch (FileNotFoundException e1) {
        getLog().error(e1);
    } catch (IOException e) {
        getLog().error(e);
    }
0

Is the file readable by your process? Try changing its permissions

chmod 777 thefile

and rerunning. If that works, then you know its a permissions issue. changing the permissions like that is probably not a permanent solution, and can be a security risk if you are on a multi-user system. But that's a different problem...

hvgotcodes
  • 114,474
  • 29
  • 200
  • 234
0

On Windows? Maybe you run your code on D: instead C:. If so put full path "c:\Users\adrian..."

It looks like default path to Eclipse workspace on Win7. If so, I have no "/Documents/" in the path. I have "/Users/myname/workspace/projectName/src....".

Piotr Gwiazda
  • 11,986
  • 12
  • 56
  • 89