Java examples for File Path IO:Directory Create
save File by creating new file and its parent folders
//package com.java2s; import java.io.File; public class Main { public static void saveFile(String destFilePathStr, String destFileName) { try {/* ww w . j a v a 2 s . c om*/ File destFilePath = new File(destFilePathStr); if (!destFilePath.exists()) { destFilePath.mkdirs(); destFilePath = null; } File destFile = new File(destFilePathStr + "//" + destFileName); if (!destFile.exists()) { destFile.createNewFile(); } } catch (Exception e) { e.printStackTrace(); } } }