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

booleanmakeDirs(final File file)
make Dirs
if (notExists(file)) {
    return file.mkdirs();
return false;
voidmakeDirs(String dir)
make Dirs
File file = new File(dir);
makeDirs(file);
booleanmakeDirs(String fileName)
make Dirs
if (fileName == null || fileName.isEmpty()) {
    return false;
String filePath = fileName.substring(0, fileName.lastIndexOf("/"));
File folder = new File(filePath);
return (folder.exists() && folder.isDirectory()) ? true : folder.mkdirs();
voidmakedirs(String fileName)
makedirs
makedirs(new File(fileName));
booleanmakeDirs(String fileName, boolean hasFile)
make Dirs
boolean result = false;
if (hasFile) {
    int lastIndex = fileName.lastIndexOf('/');
    if (lastIndex > -1) {
        String filePath = fileName.substring(0, lastIndex);
        if (filePath != null && !filePath.equals("")) {
            result = new File(filePath).mkdirs();
} else {
    result = new File(fileName).mkdirs();
return result;
booleanmakeDirs(String filePath)
make Dirs
String folderName = getFolderName(filePath);
if (folderName == null || folderName.trim().length() == 0) {
    return false;
File folder = new File(folderName);
return (folder.exists() && folder.isDirectory()) ? true : folder.mkdirs();
booleanmakeDirs(String strBottomFoldName, String strFoldName)
make Dirs
boolean blnResult = true;
File newFold = new File(strBottomFoldName, strFoldName);
if (!newFold.exists() && !newFold.mkdirs()) {
    blnResult = false;
return blnResult;
voidmakeDIRS(String[] dirs, File path)
make DIRS
File t = null;
for (String s : dirs) {
    s = path.getAbsolutePath() + File.separator + s;
    new File(s).mkdirs();
voidmakeDirsFor(File file)
Make the directories for the given file to exist in, if they don't already exist.
if (file == null) {
    throw new NullPointerException("file == null");
File parent = file.getParentFile();
if (!parent.exists()) {
    if (!parent.mkdirs()) {
        throw new RuntimeException("Unable to make directory: " + parent);
if (!parent.isDirectory()) {
    throw new RuntimeException("Not a directory: " + parent);
if (!parent.canWrite()) {
    throw new RuntimeException("Unable to write to directory: " + parent);
booleanmakeDirsWhenNotExist(String filePath)
make Dirs When Not Exist
String separator = null;
if (filePath.indexOf("/") > -1) {
    separator = "/";
} else if (filePath.indexOf("\\") > -1) {
    separator = "\\";
int index = filePath.lastIndexOf(separator);
String cataloguePath = filePath.substring(0, index);
...