List of usage examples for java.io File mkdirs
public boolean mkdirs()
From source file:Main.java
public static boolean copyFile(String src, String dest) { File test = new File(dest); if (!test.exists()) { test.mkdirs(); }//from ww w . j av a 2 s. c o m Process p; try { p = Runtime.getRuntime().exec("cp " + src + " " + dest); } catch (IOException e) { e.printStackTrace(); return false; } try { p.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return true; }
From source file:maspack.fileutil.ZipUtility.java
public static void unzip(URIx src, final File dest) throws IOException { dest.mkdirs(); final FileSystemManager fileSystemManager = VFS.getManager(); final FileObject zipFileObject = fileSystemManager.resolveFile(src.toString()); try {/*from w w w . jav a2 s. com*/ final FileObject fileSystem = fileSystemManager.createFileSystem(zipFileObject); try { fileSystemManager.toFileObject(dest).copyFrom(fileSystem, new AllFileSelector()); } finally { fileSystem.close(); } } finally { zipFileObject.close(); } }
From source file:Main.java
private static File getAlbumStorageDir(String albumName) { // Get the directory for the user's public pictures directory. File file = new File(Environment.getExternalStorageDirectory(), albumName); if (!file.mkdirs()) { Log.d(LOG_TAG, "Directory not created"); }//from w w w .j a v a2s . co m return file; }
From source file:Main.java
public static boolean createDirectory(String dir) { if (TextUtils.isEmpty(dir)) { return false; }//w w w . j av a 2 s . c o m boolean result = true; File file = new File(dir); if (!file.exists()) { result = file.mkdirs(); } return result; }
From source file:Main.java
public static final void chmod(File file) { if (file != null && !file.exists()) { file.mkdirs(); try {//from w w w .j a va 2 s . com Runtime.getRuntime().exec("chmod 555 " + file.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
public static boolean writeFile(StringBuffer sb, String fileName, String path) { String string;/* w ww . j a v a 2 s . c o m*/ DataOutputStream bfo = null; File fileDir = new File(path); if (!fileDir.exists()) fileDir.mkdirs(); try { string = sb.substring(0); bfo = new DataOutputStream(new FileOutputStream(path + fileName)); bfo.write(string.getBytes("gbk")); } catch (Exception ex) { ex.printStackTrace(); } return true; }
From source file:Main.java
public static File getAlbumDir() { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File storageDir = new File(dir, "MyAlbum"); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { return null; }/*from w w w . java2 s. co m*/ } return storageDir; } else { return null; } }
From source file:Main.java
public static String getBitmapStoragePath(Context context) { String bitmapStoragePath = ""; if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { try {//www. ja v a2 s.co m String root = context.getExternalFilesDir(null).getCanonicalPath(); if (null != root) { File bitmapStorageDir = new File(root, APP_DIR); bitmapStorageDir.mkdirs(); bitmapStoragePath = bitmapStorageDir.getCanonicalPath(); } } catch (IOException e) { e.printStackTrace(); } } return bitmapStoragePath; }
From source file:Main.java
public static File getPhotoDirectory(Activity a) { File folder = a.getExternalFilesDir(null); if (!folder.exists()) { folder.mkdirs(); System.out.println("Making bad_camera folder."); }//from w w w. ja v a 2 s . c om return folder; }
From source file:Main.java
public static void createDipPath(String file) { String parentFile = file.substring(0, file.lastIndexOf("/")); File file1 = new File(file); File parent = new File(parentFile); if (!file1.exists()) { parent.mkdirs(); try {/*from w w w . ja va 2 s . c o m*/ file1.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }