1. 程式人生 > >java建立多級目錄檔案

java建立多級目錄檔案

/**
 * 建立多級目錄檔案
 *
 * @param path 檔案路徑
 * @throws IOException
 */
private void createFile(String path) throws IOException {
    if (StringUtils.isNotEmpty(path)) {
        File file = new File(path);
        if (!file.getParentFile().exists()) {
            file.getParentFile().mkdirs();
}
        file.createNewFile();
} }