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 void saveBitmapToSD(Bitmap bitmap) {
    String root = Environment.getExternalStorageDirectory().toString();
    File myDir = new File(root + "/Download");
    myDir.mkdirs();
    Random generator = new Random();
    String fname = "Image-" + System.currentTimeMillis() + ".jpg";
    File file = new File(myDir, fname);
    if (file.exists())
        file.delete();/*from   w ww.j av  a2s  .co m*/
    try {
        FileOutputStream out = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
        out.flush();
        out.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static String getImagePath(String imageUrl) {
    int lastSlashIndex = imageUrl.lastIndexOf("/");
    String imageName = imageUrl.substring(lastSlashIndex + 1);
    String imageDir = Environment.getExternalStorageDirectory().getPath() + "/university/pics";
    File file = new File(imageDir);
    if (!file.exists()) {
        file.mkdirs();
    }/*w w  w . j  av  a 2s.  com*/
    String imagePath = imageDir + "/" + imageName;
    return imagePath;
}

From source file:Main.java

public static File getExternalCacheDir(Context context, String type) {
    File cacheDir = new File(context.getExternalCacheDir(), type);
    cacheDir.mkdirs();
    return cacheDir;
}

From source file:Main.java

public static void createDir() {
    File directory = new File("./SMART_CACHE");
    if (!directory.exists())
        directory.mkdirs();
}

From source file:Main.java

public static boolean isFolderExists(String strFolder) {
    File file = new File(strFolder);
    if (!file.exists()) {
        if (file.mkdirs()) {
            return true;
        } else//from   www .  j  a va2  s .c  om
            return false;
    }
    return true;
}

From source file:Main.java

public static String getAppCache(Context context, String dir) {
    String savePath = context.getCacheDir().getAbsolutePath() + "/" + dir + "/";
    File savedir = new File(savePath);
    if (!savedir.exists()) {
        savedir.mkdirs();
    }/*w ww .  j  av a2s  .c  om*/
    savedir = null;
    return savePath;
}

From source file:Main.java

public static String getInstancesFolder(String appName, String tableId) {
    String path;/*from   w w  w .  j  a v  a  2  s  .  c  o  m*/
    path = getTablesFolder(appName, tableId) + File.separator + INSTANCES_FOLDER_NAME;

    File f = new File(path);
    f.mkdirs();
    return f.getAbsolutePath();
}

From source file:Main.java

public static boolean createDirectory(String path) {
    File dir = new File(path);
    if (!isDirExists(path)) {
        return dir.mkdirs();
    }/*  w w w .  ja v  a 2 s  .c o m*/
    return true;
}

From source file:Main.java

public static File getFolderByPathAndCreate(String folderPath) {
    File fileFolder = new File(folderPath);
    if (!fileFolder.exists()) {
        fileFolder.mkdirs();
    }/*from w w w.j  a v a2 s. c  om*/
    return fileFolder;
}

From source file:Main.java

public static boolean createPath(String path) {
    File newfolder = new File(path);
    if (!newfolder.exists()) {
        return newfolder.mkdirs();
    }/*from  w  ww .  j a  v a 2  s.c o m*/
    return true;
}