Android Directory Create createDirIfNotExists(String d)

Here you can find the source of createDirIfNotExists(String d)

Description

create Dir If Not Exists

Declaration

public static void createDirIfNotExists(String d) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {
    public static void createDirIfNotExists(String d) {
        createDirIfNotExists(new File(d));
    }//from w  ww.  j  av a2s.c om

    public static void createDirIfNotExists(File d) {
        if (d.exists()) {
            verifyIsDir(d);
            return;
        }
        boolean created = d.mkdirs();
        if (!created)
            throw new IllegalStateException("Could not create directory "
                    + d);
    }

    private static void verifyIsDir(File f) {
        if (!f.isDirectory())
            throw new RuntimeException(f.getPath() + " is not directory");
    }
}

Related

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