SyntaxFix
Write A Post
Hire A Developer
Questions
You need to ensure that the parent directories exist before writing. You can do this by File#mkdirs().
File#mkdirs()
File f = new File("C:/a/b/test.txt"); f.getParentFile().mkdirs(); // ...