Java mkdir makeDirectory(String directoryPath)

Here you can find the source of makeDirectory(String directoryPath)

Description

Makes a directory in the given path.

License

Open Source License

Parameter

Parameter Description
directoryPath : This parametrs contains the full path of the directory.

Return

true if the operation is successed.

Declaration

public static boolean makeDirectory(String directoryPath) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**//  w w w.  jav a 2 s .c o m
     * Makes a directory in the given path.
     * 
     * @param directoryPath
     *            : This parametrs contains the full path of the directory.
     * @return true if the operation is successed.
     */
    public static boolean makeDirectory(String directoryPath) {
        File theDir = new File(directoryPath);
        boolean result = false;
        if (theDir.exists()) {
            try {
                theDir.delete();
                // System.out.println("The old directory deleted.");
                theDir.mkdir();
                result = true;
            } catch (SecurityException se) {
                System.err.println("Some problems happened while creating directory for extracting docx file.");
                return false;
            }
        }
        // if the directory does not exist, create it
        if (!theDir.exists()) {
            try {
                theDir.mkdir();
                result = true;
            } catch (SecurityException se) {
                System.err.println("Some problems happened while creating directory for extracting docx file.");
                return false;
            }
        }
        return result;
    }
}

Related

  1. makeDirectory(File testDir )
  2. makeDirectory(final CharSequence aPath)
  3. makeDirectory(final File file, final String extension)
  4. makeDirectory(String directory)
  5. makeDirectory(String directoryName)
  6. makeDirectory(String dirPath)
  7. MakeDirectory(String name)
  8. makeDirectory(String name)
  9. makeDirectory(String newDirString)