Skip to Main Content

Java Programming

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!

java.io.IOException: No such file or directory

807607Oct 4 2006 — edited Oct 4 2006
I get a java.io.IOException: No such file or directory on the following code:
try 
{
  File newfile = new File(path + filename);
  newfile.createNewFile(); // exception thrown here
} 
catch (IOException e) 
{
  System.out.println ("Eerror creating file:" + path + filename);
  System.out.println ("\n" + e);
  System.exit(-1);
}
The exception occurs when a directory does not exist.
For example, if the path is /home/joeuser/log/
and /log/ doesn't exist, the exception is thrown.
If /log/ exists, but the file does not, no problems.

What do I need to do?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 1 2006
Added on Oct 4 2006
3 comments
2,934 views