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 getCacheFullFileName(Context context, String filename) {
    File dir = context.getExternalCacheDir();
    File imgDir = new File(dir, "images");
    imgDir.mkdirs();
    return new File(imgDir, filename);
}

From source file:Main.java

/**
 * Checks a directory for existence and creates it if non-existent.
 * //from   www .ja  va2  s.com
 * @param dir
 *            directory to check/create
 */
public static void checkDirAndCreate(File dir) {
    if (!dir.exists())
        dir.mkdirs();
}

From source file:Main.java

public static boolean create(File file) throws IOException {
    if (file.exists()) {
        return true;
    }/*from  w  w w. ja v a2 s . c om*/

    File parent = file.getParentFile();
    parent.mkdirs();
    return file.createNewFile();
}

From source file:Main.java

public static boolean createEmptyFile(String path, long size) throws IOException {
    File file = new File(path);
    File parent = file.getParentFile();
    parent.mkdirs();
    RandomAccessFile raf = new RandomAccessFile(file, "rw");
    raf.setLength(size);//from w  w w  . j  a  v  a  2s  .  c om
    raf.close();
    return true;
}

From source file:Main.java

public static File createStorageFolder(String name) {
    File extStorageDirectory = Environment.getExternalStorageDirectory();
    File f = new File(extStorageDirectory, name);
    f.mkdirs();
    return f;//from   w  w w  . j  a v a2  s.  c  o  m
}

From source file:Main.java

public static boolean createEmptyFile(String path, long size) throws IOException {
    File file = new File(path);
    File parent = file.getParentFile();
    parent.mkdirs();
    RandomAccessFile raf = null;/*from w  ww. j a v a 2  s  .com*/
    raf = new RandomAccessFile(file, "rw");
    raf.setLength(size);
    raf.close();
    return true;
}

From source file:Main.java

public static boolean createFile(File file) {
    if (!file.exists())
        return file.mkdirs();
    return true;//w ww .jav a2 s.  c  o m
}

From source file:Main.java

public static Object readSeriObject(Context context, String fileName) throws Exception {
    String path = context.getFilesDir() + "/";

    File dir = new File(path);
    dir.mkdirs();
    File file = new File(dir, fileName);
    InputStream is = new FileInputStream(file);

    ObjectInputStream objectInputStream = new ObjectInputStream(is);

    Object o = objectInputStream.readObject();

    return o;/* w ww.j  a va2 s . com*/

}

From source file:Main.java

static void makeDirectoryIfNotExists(String file) {
    File f = new File(file);
    if (!(f.exists()))
        f.mkdirs();
}

From source file:Main.java

public static boolean makeSureDirectoryExists(final String dir) {
    final File file = new File(dir);
    return file.exists() || file.mkdirs();
}