Android Directory Create createDir(final File path)

Here you can find the source of createDir(final File path)

Description

Makes a directory, including any necessary but nonexistent parent directories.

Parameter

Parameter Description
path directory to create

Return

true if the directory has been created successfully

Declaration

public static boolean createDir(final File path) 

Method Source Code

import java.io.File;
import java.io.IOException;
import org.apache.log4j.Logger;

public class Main{
    private static final Logger logger = Logger.getLogger(FileUtil.class);
    /**//from   w  w w  .jav  a2s  .  co m
     * Makes a directory, including any necessary but nonexistent parent directories.
     * 
     * @param path
     *            directory to create
     * @return true if the directory has been created successfully
     */
    public static boolean createDir(final File path) {
        boolean isSuccess = false;

        if (path != null) {
            try {
                org.apache.commons.io.FileUtils.forceMkdir(path);
                isSuccess = true;
            } catch (IOException e) {
                logger.warn(e, e);
            }
        } else {
            logger.warn("Oops!.. Path is null!");
        }

        return isSuccess;
    }
}

Related

  1. createDir(String dir, boolean ignoreIfExitst)
  2. createDir(String dirName)
  3. createDir(String directory)
  4. createDir(String path)
  5. createDirIfNotExists(File d)
  6. createDirIfNotExists(String d)
  7. createDirStructureForFile(File file)
  8. createDirs(String dir, boolean ignoreIfExitst)