Android Utililty Methods Directory Create

List of utility methods to do Directory Create

Description

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

Method

voidcreateDir(String dir, boolean ignoreIfExitst)
create Dir
File file = new File(dir);
if (ignoreIfExitst && file.exists()) {
    return;
if (file.mkdir() == false) {
    throw new IOException("Cannot create the directory = " + dir);
booleancreateDir(String dirName)
create Dir
File file = new File(dirName);
if (!file.exists())
    return file.mkdir();
return true;
booleancreateDir(String directory)
creates the directory passed in, creating any parents as needed.
File f = new File(directory);
if (f.exists()) {
    return true;
} else {
    return f.mkdirs();
voidcreateDir(String path)
Creates a new directory on the machine's filesystem
File f = new File(path);
try {
    if (f.mkdir()) {
        P.println("Directory created: " + path);
    } else {
        P.println("Directory was not created" + path);
} catch (Exception e) {
...
booleancreateDir(final File path)
Makes a directory, including any necessary but nonexistent parent directories.
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;
voidcreateDirIfNotExists(File d)
create Dir If Not Exists
if (d.exists()) {
    verifyIsDir(d);
    return;
boolean created = d.mkdirs();
if (!created)
    throw new IllegalStateException("Could not create directory "
            + d);
...
voidcreateDirIfNotExists(String d)
create Dir If Not Exists
createDirIfNotExists(new File(d));
voidcreateDirStructureForFile(File file)
create Dir Structure For File
if (!file.exists()) {
    String[] dirs = file.getAbsolutePath().split(File.separator);
    String newFile = "";
    for (int index = 0; index < dirs.length - 1; index++)
        newFile += "/" + dirs[index];
    File currFile = new File(newFile);
    if (!currFile.exists())
        if (!currFile.mkdirs())
...
voidcreateDirs(String dir, boolean ignoreIfExitst)
create Dirs
File file = new File(dir);
if (ignoreIfExitst && file.exists()) {
    return;
if (file.mkdirs() == false) {
    throw new IOException("Cannot create directories = " + dir);
voidcreateDirsForFile(File file)
Create directories for file if they do not exist.
File dir = file.getParentFile();
if (dir != null) {
    directory(dir);