Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

FileOutputStream FileNotFoundException error

843789Jul 15 2010 — edited Jul 19 2010
Hi,

I am trying to write a byte[] to a png file, but I get a FileNotFoundException every time I try for some reason.
File file = new File("C:/test.png");
System.err.println(file.exists());
FileOutputStream fos = new FileOutputStream("C:/test.png");
The file.exists() returns false every time, even though the file is there, I can see it in explorer or in a command prompt, and there is no double extension or anything like that either. When I print my exception I get:

java.io.FileNotFoundException: /C:/test.png

Why is that extra slash being added? Is that what's causing the problem?

Thanks!

- Devon -
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2010
Added on Jul 15 2010
8 comments
1,779 views