List of utility methods to do Directory Create
void | mkdirs(File f) Makes sure that the directory in which the file is exists. File p = f.getParentFile();
if (!p.exists())
p.mkdirs();
|
boolean | mkDirs(File f) create all missing folders and return true, if folder on success boolean ok = false; if (f.isDirectory()) ok = true; else if (f.exists()) ok = false; else { ok = f.mkdirs(); return ok; |
void | mkdirs(File f) mkdirs if (f.exists()) { if (!f.isDirectory()) throw new RuntimeException("Expected directory " + f.getAbsolutePath() + " but found a file."); return; if (!f.mkdirs()) throw new RuntimeException("Cannot create directory " + f.getAbsolutePath()); |
List | mkdirs(File f) Like File.mkdirs() this creates all parent directories of f, but returns them in a list ArrayList<File> files = new ArrayList<File>(); if (f.isDirectory()) { files.add(f); File parentDir = f.getParentFile(); while (parentDir != null && !parentDir.exists()) { files.add(parentDir); parentDir = parentDir.getParentFile(); ... |
void | mkdirs(File file) mkdirs if (file.isDirectory()) { return; if (!file.mkdirs()) { if (file.exists()) { throw new IOException("failed to create " + file + " file exists and not a directory"); throw new IOException(); ... |
boolean | mkdirs(File file) Create all directories, including nonexistent parent directories. if (file != null) { String parent = file.getParent(); if (parent != null) { File parentDir = new File(parent); if (!parentDir.exists()) { return parentDir.mkdirs(); return true; return false; |
void | mkdirs(File file) Check and create missing parent directories for the given file. if (file.exists() && !file.isFile()) { throw new IOException("File " + file.getPath() + " is actually not a file."); File parentFile = file.getParentFile(); if (!parentFile.exists() && !parentFile.mkdirs()) { throw new IOException("Creating directories " + parentFile.getPath() + " failed."); |
void | mkdirs(File file) Create a directory hierarchy, raise an exception in case of failure. if (file != null) { if (!file.mkdirs()) { throw new IOException("Failed to create directories"); |
void | mkdirs(File file) mkdirs if (!file.exists()) {
file.mkdirs();
|
boolean | mkdirs(File file) A safer version of File.mkdirs, which works around a race in the 1.5 JDK where two VMs creating the same directory chain at the same time could end up in one VM failing to create a subdirectory. final File parentFile = file.getAbsoluteFile().getParentFile(); if (!parentFile.exists()) { mkdirs(parentFile); if (parentFile.exists()) { return file.mkdir(); } else { return false; ... |