Here you can find the source of mkDirAndFile(File file)
public static void mkDirAndFile(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static void mkDirAndFile(File file) throws IOException { if (file.exists()) { return; }/*from www. j a v a 2 s. c o m*/ if (!file.getParentFile().exists()) { mkDir(file.getParentFile()); } file.createNewFile(); } public static void mkDir(File dir) { if (dir.exists()) { return; } if (dir.getParentFile().exists()) { dir.mkdir(); } else { mkDir(dir.getParentFile()); dir.mkdir(); } } }