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...
Printable View
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...
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.