FileNotFoundException (The system cannot find the path specified)
The problem is because I'm creating a subdirectory in which to write the files. So I currently have
C:\example\
and want to write my files inC:\example\<date>\<time>\<files>
You need to call File#mkdirs()
before writing.
File file = new File("C:/example/newdir/newdir/filename.ext");
file.mkdirs();
// ...
Do assume that the computer is right and you are wrong.
And, in that scenario, the directory to which you want to write does not exit (or does not have permissions to do so).
- check the current working dir
System.getProperty("user.dir")
- debug from there
Code works for me. (Need to add a writer.close()
for text to show up in the file.)