Example usage for java.io File mkdirs

List of usage examples for java.io File mkdirs

Introduction

In this page you can find the example usage for java.io File mkdirs.

Prototype

public boolean mkdirs() 

Source Link

Document

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

Usage

From source file:Main.java

/** 
 * Create the directory for Zip file if necessary
 *///from  ww  w  .ja  v  a 2 s  . c  o  m
private static void createDestDirectoryIfNecessary(String destParam) {
    File destDir = null;
    destDir = new File(destParam);
    if (!destDir.exists()) {
        destDir.mkdirs();
    }
}

From source file:Main.java

public static String getSystemAlbumDir() {
    File file = new File(getSdCardAbsolutePath() + "/DCIM/Camera");
    if (!file.exists())
        file.mkdirs();
    return file.getAbsolutePath();
}

From source file:Main.java

/**
 * Get the external storage path of the device
 *
 * @return The external storage path of the device.
 *//*ww  w . j  ava 2  s  .  c  o m*/
public static String getStorageRootDirectory() {
    try {
        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            return null;
        }
    } catch (Exception e) {
        // Catch exception is trying to fix a crash inside of Environment.getExternalStorageState().
        e.printStackTrace();
        return null;
    }
    String rootDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
    File file = new File(rootDir);
    if (!file.exists()) {
        if (!file.mkdirs()) {
            return null;
        }
    }
    return rootDir;
}

From source file:Main.java

public static void createFolder(String sPath) {
    File file = new File(sPath);
    if (file.exists()) {
        return;//from w  w  w  . j ava  2 s  . c om
    } else {
        file.mkdirs();
    }
}

From source file:Main.java

public static File ungzip(File gzip, File toDir) throws IOException {
    toDir.mkdirs();
    File out = new File(toDir, gzip.getName());
    GZIPInputStream gin = null;//from w  ww . ja v  a  2  s . c o  m
    FileOutputStream fout = null;
    try {
        FileInputStream fin = new FileInputStream(gzip);
        gin = new GZIPInputStream(fin);
        fout = new FileOutputStream(out);
        copy(gin, fout);
        gin.close();
        fout.close();
    } finally {
        closeQuietly(gin);
        closeQuietly(fout);
    }
    return out;
}

From source file:com.wendal.java.dex.decomplier.toolkit.IO_Tool.java

public static void write2File(String rootDir, String package_name, String filename, String data)
        throws IOException {
    String tmp[] = package_name.split("[.]");
    String tmp_str = rootDir;//from  w  ww.  j av a 2s  .co  m
    for (int i = 0; i < tmp.length; i++) {
        tmp_str += "\\";
        tmp_str += tmp[i];
    }
    File dir_file = new File(tmp_str + "\\");
    dir_file.mkdirs();

    File src_file = new File(dir_file.getPath() + "\\" + filename);
    src_file.createNewFile();
    FileUtils.writeStringToFile(src_file, data);
}

From source file:Main.java

public static String getGlideDefaultPath(Context context) {
    if (context == null) {
        throw new RuntimeException("context can't be null");
    }//from ww w .j a v a  2 s  .c o m
    String path = context.getCacheDir().getAbsolutePath();
    if (isSDCard()) {
        String directory = Environment.getExternalStorageDirectory() + "/GankLy/cache/img";
        File file = new File(directory);
        if (!file.exists()) {
            if (file.mkdirs()) {
                return directory;
            }
        }
    }
    return path;
}

From source file:Main.java

/**
 * Get the external storage path of the device
 *
 * @return The external storage path of the device.
 *//*  www.  j a v a 2 s  .  c  om*/
public static String getAppRootDirectory() {
    try {
        if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            return null;
        }
    } catch (Exception e) {
        // Catch exception is trying to fix a crash inside of Environment.getExternalStorageState().
        e.printStackTrace();
        return null;
    }
    String rootDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + ROOT_DIR + "/";
    File file = new File(rootDir);
    if (!file.exists()) {
        if (!file.mkdirs()) {
            return null;
        }
    }
    return rootDir;
}

From source file:Main.java

public static File getSaveFolder(String folderName) {
    File file = new File(getSDCardPath() + File.separator + folderName + File.separator);
    file.mkdirs();
    return file;/*from w w w .j a v a 2s.  c  o m*/
}

From source file:Main.java

public static File[] getFiles() {
    File fileDir = getFilesDirectory(STORAGE_PATH);
    if (!fileDir.exists()) {
        if (!fileDir.mkdirs()) {
            return null;
        }/*  w ww.j av  a  2s .  c  o m*/
    }
    return fileDir.listFiles();
}