Here you can find the source of makeDirForPath(String path)
public static void makeDirForPath(String path)
//package com.java2s; import java.io.File; public class Main { public static String fileseperator = System.getProperty("file.separator"); public static void makeDirForPath(String path) { File file = new File(path); File dir = new File(file.getParent()); makeDir(dir.getPath());//from ww w . j av a2 s. c o m } /** * @param path */ public static synchronized void makeDir(String path) { File dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } } /** * create directory method * * @param parent directory * @param child directory */ public static synchronized void makeDir(String parent, String child) { StringBuffer mkdir = new StringBuffer(parent); mkdir.append(fileseperator); mkdir.append(child); makeDir(mkdir.toString()); } }