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 File creatSDDir(String dirRelativePath) {
    File dir = new File(SD_CARD_PATH + dirRelativePath);
    dir.mkdirs();
    return dir;//w  ww.ja  va2  s.  c  om
}

From source file:Main.java

private static File getFile(Context context, String fileName) {

    File dir = context.getCacheDir();
    dir.mkdirs();
    File file = new File(dir, fileName);

    return file;/*w  ww.ja v a 2s.c o  m*/
}

From source file:Main.java

private static void makeDirs(String fileName) {
    // get the last / or \ position, return if not found
    int lastSlashPos = fileName.lastIndexOf("/");
    if (lastSlashPos == -1) {
        lastSlashPos = fileName.lastIndexOf("\\");

        if (lastSlashPos == -1) {
            return;
        }//ww w  .  j a va  2s.  c o  m
    }

    String folderPath = fileName.substring(0, lastSlashPos);
    File folderFile = new File(folderPath);
    folderFile.mkdirs();
}

From source file:Main.java

/**
 * Creates a directory and sub directories if needed
 * //  w  w w  .  j a v  a 2  s.c  o m
 * @param dir
 *            {@link File}
 */
public static void createDir(File dir) {
    if (dir != null)
        dir.mkdirs();
}

From source file:Main.java

public static void checkDir(File dir) {
    if (dir != null && !dir.exists()) {
        dir.mkdirs();
    }
}

From source file:Main.java

public static File getDefaultDirectory() throws Exception {
    File extdir = Environment.getExternalStorageDirectory();
    File directory = new File(extdir, SD_DIRECTORY + "/");
    directory.mkdirs();
    return directory;
}

From source file:Main.java

public static void saveSeriObj(Context context, String fileName, Object o) throws Exception {

    String path = context.getFilesDir() + "/";

    File dir = new File(path);
    dir.mkdirs();

    File f = new File(dir, fileName);

    if (f.exists()) {
        f.delete();//  ww w  .j  a v a 2  s  . co m
    }
    FileOutputStream os = new FileOutputStream(f);
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);
    objectOutputStream.writeObject(o);
    objectOutputStream.close();
    os.close();
}

From source file:Main.java

public static File getLetterCacheDir(Context context) {
    File cache = new File(context.getCacheDir() + "/letters/");
    cache.mkdirs();
    return cache;
}

From source file:Main.java

public static File ensureDirExists(File dir) throws IOException {
    if (!(dir.isDirectory() || dir.mkdirs())) {
        throw new IOException("Couldn't create directory '" + dir + "'");
    }/*from   w  ww .j  av  a  2  s.c o  m*/
    return dir;
}

From source file:Main.java

public static void createFileDir(String dir) {
    File file = new File(dir);
    if (!file.exists()) {
        file.mkdirs();
    }/*from   ww w .  j  a v  a  2 s.  c om*/
}