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

public static String getPrivateFilePath(Context context, String yourAppPath) {
    String PATH = context.getFilesDir().getAbsolutePath() + yourAppPath;
    File file = new File(PATH);
    if (!(file.exists() && file.isDirectory())) {
        file.mkdirs();
    }/*from  ww w.  jav  a2 s.c o m*/

    return PATH;
}

From source file:ee.ioc.phon.android.inimesed.MyFileUtils.java

public static void saveFile(File f, String content) throws IOException {
    File dir = f.getParentFile();
    if (!dir.exists() && !dir.mkdirs()) {
        throw new IOException("Cannot create directory: " + dir);
    }/*from   w  ww .j av a  2s.c  om*/
    FileUtils.writeStringToFile(f, content, "UTF8");
}

From source file:Main.java

public static File getSaveGameDir() {

    if (savesDir != null) {
        return savesDir;
    }//from   w  w w .  j  av a  2  s  . c o m

    File userHome = new File(System.getProperty("user.home"));
    File userMaps = new File(userHome, "saves");
    if (!userMaps.isDirectory() && !userMaps.mkdirs()) { // if it does not exist and i cant make it
        throw new RuntimeException("can not create dir " + userMaps);
    }

    savesDir = userMaps;
    return userMaps;
}

From source file:Main.java

public static void dirChecker(String directoryPath) {
    File f = new File(directoryPath);

    if (!f.isDirectory()) {
        f.mkdirs();
    }/*ww w .  j  a v  a  2s . c  o m*/
}

From source file:com.thoughtworks.go.util.TestFileUtil.java

public static File createTestFolder(File parent, String folderName) {
    File subDir = new File(parent, folderName);
    subDir.mkdirs();
    subDir.deleteOnExit();//from w  w  w .jav a 2s. c  om
    return subDir;
}

From source file:Main.java

private static String getSDDir(String key_dir) {
    StringBuilder sb = new StringBuilder();
    String absolutePath = Environment.getExternalStorageDirectory().getAbsolutePath();// /mnt/sdcard
    sb.append(absolutePath);/* w w  w.  j a  v a2 s  . com*/
    sb.append(File.separator).append(ROOT_DIR).append(File.separator).append(key_dir);

    String filePath = sb.toString();
    File file = new File(filePath);
    if (!file.exists()) {
        if (file.mkdirs()) {
            return file.getAbsolutePath();
        } else {
            return "";
        }
    }

    return file.getAbsolutePath();
}

From source file:Main.java

public static String getPublicDataFolder() {
    StringBuilder publicFolder = new StringBuilder();
    publicFolder.append(Environment.getExternalStorageDirectory()).append(DIRECTORY_NAME);
    File new_dir = new File(publicFolder.toString());
    if (!new_dir.exists()) {
        new_dir.mkdirs();
    }/*from   www . ja v a 2  s  .  c  o m*/
    return publicFolder.toString();
}

From source file:Main.java

public static File getSaveMapDir() {

    if (mapsDir != null) {
        return mapsDir;
    }/*from   w w  w .ja  v  a  2s. c  o m*/

    File userHome = new File(System.getProperty("user.home"));
    File userMaps = new File(userHome, "maps");
    if (!userMaps.isDirectory() && !userMaps.mkdirs()) { // if it does not exist and i cant make it
        throw new RuntimeException("can not create dir " + userMaps);
    }

    mapsDir = userMaps;
    return userMaps;
}

From source file:Main.java

public static final boolean createFolder(String path) {
    if (storageReady()) {
        boolean made = true;
        File dir = new File(path);
        if (!dir.exists()) {
            made = dir.mkdirs();
        }/*from  ww  w . j a  v  a2s . c  om*/
        return made;
    } else {
        return false;
    }
}

From source file:Main.java

public static boolean createDirs(String dirPath) {
    File file = new File(dirPath);
    if (!file.exists() || !file.isDirectory()) {
        return file.mkdirs();
    }/*from  w  w  w . j  a  va  2s  .  c o m*/
    return true;
}