How to create a new file together with missing parent directories?
Have you tried this?
file.getParentFile().mkdirs();
file.createNewFile();
I don't know of a single method call that will do this, but it's pretty easy as two statements.
As of java7, you can also use NIO2 API:
void createFile() throws IOException {
Path fp = Paths.get("dir1/dir2/newfile.txt");
Files.createDirectories(fp.getParent());
Files.createFile(fp);
}