List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:Main.java
public static File getUploadFolder() { File file = Environment.getExternalStorageDirectory(); File path = new File(file, File.separator + "farm" + ""); if (!path.exists()) path.mkdir(); return path;//from w ww . ja va2s . c o m }
From source file:Utils.java
/** * Creates a new empty temporary directory. *///from w w w .j av a 2 s. c om public static File createTmpDir() throws IOException { // create a temporary directory File tmpFile = File.createTempFile("tmp", "tmp", new File(".")); tmpFile.delete(); tmpFile.mkdir(); return tmpFile; }
From source file:Main.java
public static File save2File(String savePath, String saveName, String crashReport) { try {/*from w w w . ja v a 2 s . co m*/ File dir = new File(savePath); if (!dir.exists()) dir.mkdir(); File file = new File(dir, saveName); FileOutputStream fos = new FileOutputStream(file); fos.write(crashReport.toString().getBytes()); fos.close(); return file; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getSaveImagePath(Context context) { String path = getCacheDir(context).getAbsolutePath(); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { path = Environment.getExternalStorageDirectory().getAbsolutePath(); }/*from w w w . j ava 2s .com*/ path = path + File.separator + "Pictures"; File file = new File(path); if (!file.exists()) { file.mkdir(); } return path; }
From source file:Main.java
private static void createFolderUnderPrivate(String folderName) { String folderPathString = getSDPath() + mPrivatePath; checkSDPrivateFolder();// w w w . j a v a 2 s . c om String newFolder = folderPathString + folderName + "/"; File path = new File(newFolder); if (!path.exists()) { path.mkdir(); } }
From source file:Main.java
public static void copyDirectory(File srcDir, File dstDir) throws IOException { if (srcDir.isDirectory()) { if (!dstDir.exists()) { dstDir.mkdir(); }/* ww w . j a va2 s . c o m*/ String[] children = srcDir.list(); for (int i = 0; i < children.length; i++) { copyDirectory(new File(srcDir, children[i]), new File(dstDir, children[i])); } } else { copyFile(srcDir, dstDir); } }
From source file:Main.java
public static void writeInteractionInFile(Context context, String startTime, String endTime, long duration, String filename) throws IOException, Exception { BufferedWriter writer = null; //String path="sdcard/LifeTracker/lifetracker.csv"; File dir = new File("sdcard/SleepLog"); boolean flag = dir.mkdir(); //Log.d("Directory created?",""+flag); File file = new File(dir.getAbsolutePath(), filename); if (file.exists() == false) { // Intent service = new Intent(context,DataBaseService.class); // context.startService(service); file.createNewFile();/*from w w w . jav a 2 s.c o m*/ writer = new BufferedWriter(new FileWriter(file, true)); writer.write("Start Time,End Time,Duration"); writer.newLine(); writer.write(startTime + "," + endTime + "," + duration); } else { writer = new BufferedWriter(new FileWriter(file, true)); writer.newLine(); writer.write(startTime + "," + endTime + "," + duration); } Log.d("Appended", "True"); writer.flush(); writer.close(); }
From source file:Main.java
public static void copyDirectory(File srcDir, File dstDir) throws IOException { if (srcDir.isDirectory()) { if (!dstDir.exists()) { dstDir.mkdir(); }//from ww w . j a v a 2 s . c o m String[] children = srcDir.list(); for (int i = 0; i < children.length; i++) { copyDirectory(new File(srcDir, children[i]), new File(dstDir, children[i])); } } else { copyFile(srcDir, dstDir); } }
From source file:net.bpelunit.util.FileUtil.java
public static File createTempDirectory() throws IOException { File tmp = File.createTempFile("bpelunit", ""); tmp.delete();//from ww w .ja v a 2s . c o m tmp.mkdir(); return tmp; }
From source file:Main.java
public static void makeDir(File dir) { if (!dir.getParentFile().exists()) { makeDir(dir.getParentFile());// w w w . ja v a2 s . c o m } dir.mkdir(); }