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

voidforceMkdir(File dir)
force Mkdir
boolean success = dir.isDirectory();
if (!success) {
    success = dir.mkdirs();
checkSuccess(success, "Cannot create directory " + dir);
voidforceMkdir(File directory)
force Mkdir
if (directory.exists()) {
    if (directory.isFile()) {
        throw new IOException(
                "File " + directory + " exists and is not a directory. Unable to create directory.");
} else {
    if (!directory.mkdirs()) {
        throw new IOException("Unable to create directory " + directory);
...
voidforceMkdir(File directory)
Make a directory, including any necessary but nonexistent parent directories.
if (directory.exists()) {
    if (directory.isFile()) {
        String message = "File " + directory + " exists and is "
                + "not a directory. Unable to create directory.";
        throw new IOException(message);
} else {
    if (!directory.mkdirs()) {
...
voidforceMkdir(File directory)
force Mkdir
if (directory.exists()) {
    if (directory.isFile()) {
        String message = "File " + directory + " exists and is "
                + "not a directory. Unable to create directory.";
        throw new IOException(message);
} else {
    if (false == directory.mkdirs()) {
...
FileforceMkdir(String filePath)
Create a file or folder from specified path or the directory cannot be created then an exception is thrown.
File directory = new File(filePath);
if (!directory.exists()) {
    if (!directory.mkdirs())
        return null;
return directory;
voidforceMkdirs(File file)
force Mkdirs
if (file.exists() && file.isFile()) {
    throw new IOException("File [" + file + "] exists and is not a directory. Unable to create directory.");
if (!file.mkdirs()) {
    throw new IOException("Unable to create directory: " + file);
voidmakeDir(File dir)
make Dir
if (!dir.exists()) {
    if (!dir.getParentFile().exists()) {
        makeDir(dir.getParentFile());
    dir.mkdir();
voidmakeDir(File dir)
Make the given folder (and any parent folders), throws an IOException on failure.
makeDir(dir, null);
StringmakeDir(File f)
If the directory defined in the given argument f does not exist then make it.
if (!f.exists()) {
    if (!f.mkdir()) {
        System.out.println("Failed to make directory " + f.getPath());
return f.getPath();
booleanmakeDir(File file)
Common file operators
if (!file.exists()) {
    return file.mkdirs();
return true;