Here you can find the source of makeDirsWhenNotExist(String filePath)
private static boolean makeDirsWhenNotExist(String filePath)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { private static boolean makeDirsWhenNotExist(String filePath) { String separator = null;/*from w ww .j a va 2 s. com*/ if (filePath.indexOf("/") > -1) { separator = "/"; } else if (filePath.indexOf("\\") > -1) { separator = "\\"; } int index = filePath.lastIndexOf(separator); String cataloguePath = filePath.substring(0, index); File file = new File(cataloguePath); if (!file.exists()) { file.mkdirs(); } return true; } }