Here you can find the source of mkdir(File dirFile)
Parameter | Description |
---|---|
dirFile | a parameter |
public static void mkdir(File dirFile)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/*w ww .ja v a 2 s .c om*/ * Create a directory by calling mkdir(); * * @param dirFile */ public static void mkdir(File dirFile) { try { // File dirFile = new File(mkdirName); boolean bFile = dirFile.exists(); if (bFile == true) { System.err.println("The folder exists."); } else { System.err.println("The folder do not exist,now trying to create a one..."); bFile = dirFile.mkdir(); if (bFile == true) { System.out.println("Create successfully!"); } else { System.err.println("Disable to make the folder,please check the disk is full or not."); } } } catch (Exception err) { System.err.println("ELS - Chart : unexpected error"); err.printStackTrace(); } } public static void mkdir(File file, boolean b) { if (b) {// true delete first deleteDirectory(file); mkdir(file); } else { mkdir(file); } } /** * * @param path * @return */ static public boolean deleteDirectory(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete(); } } } return (path.delete()); } /** * List files in a given directory * * */ static public String[] listFiles(String inputdir) { File dir = new File(inputdir); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i = 0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; } } return children; } }