List of utility methods to do Create Directory
Boolean | mkdirIfMissing(File dir) mkdir If Missing return !dir.exists() && dir.mkdir();
|
int | mkdirIfNotExists(File dir) 0: dir not created because it already exists 1: dir created -1: dir needs to be created, but failed if (!dir.exists()) { if (dir.mkdirs()) { return 1; } else { return -1; } else { return 0; ... |
boolean | mkDirRec(File file) Creates all required directories for the provided file. if (file == null) return true; if (!file.exists()) { if (!mkDirRec(file.getParentFile())) return false; if (!file.mkdir()) return false; if (!file.isDirectory()) return false; return true; |
void | mkdirs(File folder) mkdirs if (folder != null) { if (!folder.isDirectory()) { if (!folder.mkdirs()) { throw new RuntimeException("Unable to create directory " + folder.getAbsolutePath()); |
void | mkdirs(File outdir, String path) mkdirs File d = new File(outdir, path); if (!d.exists()) d.mkdirs(); |
File | mkdirs(File parent, String name, boolean mkdirs) Creates and returns a File for the given path and name. return mkdirs(new File(parent, name), mkdirs); |
boolean | mkDirs(File path) mk Dirs return path.mkdirs();
|
void | mkdirs(File path) mkdirs if (!path.mkdirs()) { throw new IOException("Can't create folder(s): " + path); |
boolean | mkdirs(File path) File.mkdirs() method doesn't work when multiple threads are creating paths with a common parent directory simultaneously. if (path.exists()) { return true; if (path.mkdir() || path.exists()) { return true; File canonFile = null; try { ... |
File | mkdirs(File path) mkdirs path = getCleanAbsolutePath(path); if (!path.exists()) { if (!path.mkdirs()) { throw new IOException("Could not mkdirs " + path.getAbsolutePath()); return path; |