List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:Main.java
public static void checkDir() { String sdState = android.os.Environment.getExternalStorageState(); if (sdState.equals(android.os.Environment.MEDIA_MOUNTED)) { File dir = new File(PATH); if (!dir.exists()) { File dir2 = new File("sdcard/Ancached_Browser/"); if (!dir2.exists()) { dir2.mkdir(); }//ww w . ja va 2 s . c o m dir.mkdir(); } } }
From source file:Main.java
public static String GetBackupFolder(Context paramContext) { File dir = new File(Environment.getExternalStorageDirectory(), "backups"); if (!dir.exists()) dir.mkdir(); return PreferenceManager.getDefaultSharedPreferences(paramContext).getString("prefDBLocalFolder", dir.getAbsolutePath());//from w w w. jav a2 s . co m }
From source file:Main.java
public static Boolean createPath(String path) { File file = new File(path); if (file.exists()) { return true; } else {/*from w w w . jav a 2 s . com*/ if (file.mkdir()) { return true; } } return false; }
From source file:Main.java
public static File getDiskCacheFile(Context context, String key) { final String cachePath = context.getFilesDir().getPath(); File cacheDir = new File(cachePath + File.separator + DISK_CACHE_SUBDIR); if (!cacheDir.exists()) { cacheDir.mkdir(); }/*from w w w. j a va2 s . c o m*/ return new File(cacheDir + File.separator + key); }
From source file:Main.java
public static File getChronosDir() { String chronosHome = getUserHomeDir() + File.separator + CHRONOS_DIR_NAME; File file = new File(chronosHome); if (!file.exists() || !file.isDirectory()) { file.mkdir(); }//from w w w . j a va 2s . com return file; }
From source file:Main.java
public static void savePic2SD(Bitmap bitmap, String path, String folder) { boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); if (sdCardExist) { File fileDir = new File(folder); if (!fileDir.exists()) { fileDir.mkdir(); }/*from ww w .ja va 2 s . c o m*/ } File file = new File(path); try { FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void upZipFile(File zipFile, String folderPath) { ZipFile zf;//w w w. java 2 s .c om try { zf = new ZipFile(zipFile); for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements();) { ZipEntry entry = ((ZipEntry) entries.nextElement()); if (entry.isDirectory()) { String dirstr = entry.getName(); dirstr = new String(dirstr.getBytes("8859_1"), "GB2312"); File f = new File(dirstr); f.mkdir(); continue; } InputStream in = zf.getInputStream(entry); String str = folderPath + File.separator + entry.getName(); str = new String(str.getBytes("8859_1"), "GB2312"); File desFile = new File(str); if (!desFile.exists()) { File fileParentDir = desFile.getParentFile(); if (!fileParentDir.exists()) { fileParentDir.mkdirs(); } desFile.createNewFile(); } OutputStream out = new FileOutputStream(desFile); byte buffer[] = new byte[BUFF_SIZE]; int realLength; while ((realLength = in.read(buffer)) > 0) { out.write(buffer, 0, realLength); } in.close(); out.close(); } } catch (ZipException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static File getTempFile(String packageName) { final File path = new File(Environment.getExternalStorageDirectory(), packageName); if (!path.exists()) { path.mkdir(); }//from w w w . j av a 2 s . com return new File(path, "image.tmp"); }
From source file:Main.java
public static File saveBmpFile(Bitmap bmp, String filePath, String fileName) { File dirFile = new File(filePath); if (!dirFile.exists()) { dirFile.mkdir(); }/*from w ww .ja v a 2s . c o m*/ File wantSaveFile = new File(filePath + "/" + fileName); try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(wantSaveFile)); if (fileName.contains(".jpg")) { bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos); } else { bmp.compress(Bitmap.CompressFormat.PNG, 100, bos); } bos.flush(); bos.close(); } catch (IOException e) { e.printStackTrace(); } return wantSaveFile; }
From source file:Main.java
public static File getAudioDirectory() { File audioDirectory = new File(getMultimediaDirectory(), "audio"); if (!audioDirectory.exists()) { audioDirectory.mkdir(); }// w ww.j a v a2 s .c o m return audioDirectory; }