Java Utililty Methods mkdir

List of utility methods to do mkdir

Description

The list of methods to do mkdir are organized into topic(s).

Method

booleanmakeDirectory(String path, String directoryName)
Create a directory in the given path
File f = new File(path, directoryName);
if (!f.exists()) {
    return f.mkdir();
return false;
voidmakeDirectory(String sDir)
make Directory
File fDir = new File(sDir);
if (!fDir.exists())
    fDir.mkdirs();
if (fDir.isFile()) {
    throw new java.io.IOException("The file with the same name already exists. - " + sDir);
voidmakeDirectoryWorldAccessible(File directory)
make Directory World Accessible
if (!directory.isDirectory()) {
    throw new IOException(directory + " must be a directory");
makeWorldReadable(directory);
if (!directory.setExecutable(true, false )) {
    throw new IOException("Unable to make " + directory + " world-executable");
voidmakeDirForPath(String path)
make Dir For Path
File file = new File(path);
File dir = new File(file.getParent());
makeDir(dir.getPath());
voidmakeDirIfNotExists(File... paths)
Create any directory in the list paths if it doesn't exist
for (File f : paths) {
    makeDirIfNotExists(f.getAbsolutePath());
voidmakeDirRecursive(File f)
Make the directory.
if (f == null) {
    return;
if (f.exists()) {
    return;
makeDirRecursive(f.getParentFile());
f.mkdir();
...
voidmakeDirs(@Nullable File dir)
Creates dir and its parents
if (dir != null && !dir.exists() && !dir.mkdirs()) {
    throw new IOException("unable to create directory (or parents): " + dir);
booleanmakeDirs(File dir, int numTries)
Create a directory and its parent directories if necessary.
if (numTries < 1) {
    throw new IllegalArgumentException("number of tries must be greater than zero");
int tries = 0;
while (tries++ < numTries) {
    boolean result = dir.mkdirs();
    if (result) {
        return true;
...
booleanmakeDirs(File f)
Make a directory and its parents, returning true if and only if the dir exists.
if (f.exists()) {
    if (!f.isDirectory()) {
        return false;
    return true;
return f.mkdirs();
voidmakeDirs(File file)
make Dirs
file = new File(file.getAbsolutePath());
File parent = file.getParentFile();
if (!parent.exists())
    makeDirs(parent);
parent.mkdir();