List of utility methods to do Directory Create
void | createIfDoesntExist(File dir, boolean mustBeReadable, boolean mustBeWritable) creates a directory if it doesnt exist and verifies permissions if (dir.exists()) { if (!dir.isDirectory()) throw new IOException(dir.getAbsolutePath() + " exists but isn't a directory"); } else { if (!dir.mkdirs()) throw new IOException("Couldn't create directory " + dir.getAbsolutePath()); ... |
boolean | createMissingParentDirectories(File file) create Missing Parent Directories File parent = file.getParentFile(); if (parent == null) { throw new IllegalStateException(file + " should not have a null parent"); if (parent.exists()) { throw new IllegalStateException(file + " should not have existing parent directory"); ... |
File | createNewDirectory(String directorPath) create New Directory File dir = new File(directorPath); if (dir.exists()) return dir; dir.mkdirs(); return dir; |
File | createOrGetDir(String path, boolean mustBeReadable, boolean mustBeWritable) Creates a directory or gets it if it exists. File dir = new File(path); createIfDoesntExist(dir, mustBeReadable, mustBeWritable); return dir; |
boolean | dirWritable(String dir) dir Writable return dirWritable(new File(dir)); |
File | directory(File base, String dir) Returns the File for a named directory. return directory(base.getPath(), dir);
|
File | directory(File dir) Returns the File for a directory. if (!dir.exists()) { if (!dir.mkdirs()) { throw new IOException(Fmt.S("can't create directory %s", dir)); if (!dir.isDirectory()) { throw new IOException(Fmt.S("%s is not a directory", dir)); ... |
File | directory(String base, String dir) Returns the File for a named directory. return directory(new File(new File(base), dir)); |
File | directory(String dir) Returns the File for a named directory. return directory(new File(dir)); |
void | ensureDirectoryExist(File dir) ensure Directory Exist if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) throw new IOException("Cannot create directory"); } else { if (!dir.isDirectory()) throw new IOException(dir.getName() + " is not a directory"); |