Java Utililty Methods mkdir

List of utility methods to do mkdir

  1. HOME
  2. Java
  3. m
  4. mkdir

Description

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

Method

void forceMkdir(File dir)
force Mkdir
boolean success = dir.isDirectory();
if (!success) {
 success = dir.mkdirs();
checkSuccess(success, "Cannot create directory " + dir);
void forceMkdir(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);
...
void forceMkdir(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()) {
...
void forceMkdir(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()) {
...
File forceMkdir(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;
void forceMkdirs(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);
void makeDir(File dir)
make Dir
if (!dir.exists()) {
 if (!dir.getParentFile().exists()) {
 makeDir(dir.getParentFile());
 dir.mkdir();
void makeDir(File dir)
Make the given folder (and any parent folders), throws an IOException on failure.
makeDir(dir, null);
String makeDir(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();
boolean makeDir(File file)
Common file operators
if (!file.exists()) {
 return file.mkdirs();
return true;


AltStyle によって変換されたページ (->オリジナル) /