Click to See Complete Forum and Search --> : Cannot create a file?


May 11th, 2000, 05:01 PM
Hello.... I have code which reads/writes fine to a file but if the file does not exist it throws filenotfoundexception... OK how can I create the file?

Thanks in advance ... really appreciate the help...

May 12th, 2000, 04:17 AM
Where is the code?
Anyway.
To create a file simply do this
To read from existing file

File f = new File("filename"); //if doesn't exist, it'll be created automatically
FileInpustream fis = new FileInputStream(f);

to write to file create FileOutputStream instead.