Android Directory Create ensureDirectoryExist(File dir)

Here you can find the source of ensureDirectoryExist(File dir)

Description

ensure Directory Exist

Declaration

public static void ensureDirectoryExist(File dir) throws IOException 

Method Source Code

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

import java.io.IOException;

public class Main {
    public static void ensureDirectoryExist(File dir) throws IOException {
        if (!dir.exists()) {
            boolean success = dir.mkdirs();
            if (!success)
                throw new IOException("Cannot create directory");
        } else {//w w  w. ja v  a 2s  .  co  m
            if (!dir.isDirectory())
                throw new IOException(dir.getName() + " is not a directory");
        }
    }
}

Related

  1. dirWritable(String dir)
  2. directory(File base, String dir)
  3. directory(File dir)
  4. directory(String base, String dir)
  5. directory(String dir)
  6. getDir(String path)
  7. isParentDirectoryCreationRequired(File file)
  8. join(String dir, String subDir)
  9. makeDirs(File f)