List of usage examples for java.io File mkdirs
public boolean mkdirs()
From source file:com.tasktop.c2c.server.scm.service.GitServiceTestBase.java
public static void ensureDirExists(File dir) throws IOException { if (!dir.exists()) { dir.mkdirs(); }/*from w ww . jav a2 s. c o m*/ }
From source file:com.tasktop.c2c.server.scm.service.GitServiceTestBase.java
public static void ensureDirExistsAndIsEmpty(String dir) throws IOException { File file = new File(dir); if (!file.exists()) { file.mkdirs(); } else {/*from w w w. jav a 2 s. c o m*/ FileUtils.deleteDirectory(file); } }
From source file:com.tealcube.minecraft.bukkit.facecore.utilities.IOUtils.java
/** * Create a directory from the given {@link java.io.File}. * * @param file directory to create//from w w w . j a v a 2 s .c o m * @return if creation was successful */ public static boolean createDirectory(File file) { Validate.notNull(file, "file cannot be null"); return file.exists() || file.mkdirs(); }
From source file:Main.java
public static boolean createDiretory(File dir) { if (dir == null) { return false; }/*from ww w . ja va2 s. c o m*/ if (dir.exists() && dir.isDirectory()) { return true; } return dir.mkdirs(); }
From source file:Main.java
public static void writeToPublicDirectory(String filename, byte[] data, String directory, String environmentDirectory) throws Exception { File publicDirectory = new File(Environment.getExternalStoragePublicDirectory(environmentDirectory), directory);/*from w ww. jav a 2s . c om*/ boolean result = publicDirectory.mkdirs(); File targetFile = new File(publicDirectory, filename); FileOutputStream fileOutputStream = new FileOutputStream(targetFile); fileOutputStream.write(data); fileOutputStream.close(); }
From source file:Main.java
public static File getFilesSubDirectory(Context context, String filesSubDir) { File appFilesSubDir = new File(getFilesDirectory(context), filesSubDir); if (!appFilesSubDir.exists()) appFilesSubDir.mkdirs(); //String filename = String.valueOf(url.hashCode()); // Another possible solution (thanks to grantland) // String filename; /*/*from w ww . j ava2 s . c o m*/ * try { filename = URLEncoder.encode(url, "UTF-8"); } catch * (UnsupportedEncodingException e) { * e.printStackTrace(); } */ return appFilesSubDir; }
From source file:com.cloudant.sync.util.TestUtils.java
public static String createTempTestingDir(String dirPrefix) { String tempPath = String.format("%s_%s", dirPrefix, UUID.randomUUID().toString()); File f = new File(FileUtils.getTempDirectory().getAbsolutePath(), tempPath); f.mkdirs(); return f.getAbsolutePath(); }
From source file:com.slimroms.themecore.AssetUtils.java
public static boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath, Cipher cipher) { InputStream in;/* w ww . j a v a2s . c o m*/ File parent = new File(toPath).getParentFile(); if (!parent.exists() && !parent.mkdirs()) { Log.d(TAG, "Unable to create " + parent.getAbsolutePath()); } try { in = assetManager.open(fromAssetPath); if (cipher != null && fromAssetPath.endsWith(".enc")) { in = new CipherInputStream(in, cipher); if (toPath.endsWith(".enc")) { toPath = toPath.substring(0, toPath.lastIndexOf(".")); } } String text = IOUtils.toString(in, Charset.defaultCharset()); Log.d("TEST", "text=" + text); copyInputStreamToFile(in, new File(toPath)); in.close(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:io.wcm.devops.conga.generator.util.FileUtil.java
/** * Ensure that directory exists and create it if not. * @param dir Directory//from w w w. ja va2 s.c om * @return Directory */ public static File ensureDirExistsAutocreate(File dir) { if (!dir.exists()) { dir.mkdirs(); } if (!dir.isDirectory()) { throw new IllegalArgumentException("Path is not a directory: " + getCanonicalPath(dir)); } return dir; }