Here you can find the source of createDirStructureForFile(File file)
@SuppressWarnings("unused") public static void createDirStructureForFile(File file)
//package com.java2s; import java.io.File; public class Main { @SuppressWarnings("unused") public static void createDirStructureForFile(File file) { if (!file.exists()) { String[] dirs = file.getAbsolutePath().split(File.separator); String newFile = ""; for (int index = 0; index < dirs.length - 1; index++) newFile += "/" + dirs[index]; File currFile = new File(newFile); if (!currFile.exists()) if (!currFile.mkdirs()) throw new RuntimeException( "Could not create directory: " + currFile.getAbsolutePath()); }/*from w w w .j a v a 2 s . c o m*/ } }