List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:com.linkedin.pinot.tools.admin.command.StartZookeeperCommand.java
public static File createAutoDeleteTempDir() { File tempdir = Files.createTempDir(); tempdir.delete();//from w w w .j av a2s . c om tempdir.mkdir(); tempdir.deleteOnExit(); return tempdir; }
From source file:Main.java
public static String getCacheFolder(Context context) { File cacheFolder = new File(context.getCacheDir().getAbsolutePath() + File.separator + "app_icons"); if (!cacheFolder.exists()) { cacheFolder.mkdir(); }/*from www . j a v a 2s. c o m*/ return cacheFolder.getAbsolutePath(); }
From source file:Main.java
public static File getStudentImageDirectory() { File studentImageDirectory = new File(getMultimediaDirectory(), "studentImage"); if (!studentImageDirectory.exists()) { studentImageDirectory.mkdir(); }/*from ww w . j a v a 2s . co m*/ return studentImageDirectory; }
From source file:Main.java
public static void startRecord() { if (!haveStarted) { haveStarted = true;//from w ww. ja v a 2 s. c om mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); File pp = new File(path); if (!pp.isDirectory() && !pp.exists()) { pp.mkdir(); } currentFilePath = path + new SimpleDateFormat("yyyyMMddHHmmss").format(System.currentTimeMillis()) + ".mp3"; File saveFilePath = new File(currentFilePath); mRecorder.setOutputFile(saveFilePath.getAbsolutePath()); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); try { mRecorder.prepare(); } catch (IOException e) { Log.e(TAG, "prepare() failed"); } mRecorder.start(); } }
From source file:Main.java
public static void saveJpegFile(String fileName, Bitmap bitmap) { // file// w ww.j av a2s . c o m File file = new File(extStorageDirectory, fileName + ".jpg"); File fileDirectory = new File(extStorageDirectory); if (!fileDirectory.exists()) { fileDirectory.mkdir(); } OutputStream outStream = null; try { outStream = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream); outStream.flush(); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void CreateCustomFolderForLanguage() { File direct = new File(Environment.getExternalStorageDirectory() + "/WFP/Language/"); if (!direct.exists()) { if (direct.mkdir()) { File languageFolder = new File("/WFP/Language/"); languageFolder.mkdirs();/*from ww w . ja v a 2 s .c o m*/ } } else { } }
From source file:Main.java
public static void createDirectoryIfNotExists(String directoryName) { File recordingsDirectory = new File(Environment.getExternalStorageDirectory(), directoryName); if (!recordingsDirectory.exists()) { recordingsDirectory.mkdir(); }/*from w w w.j av a2 s. c om*/ }
From source file:cop.raml.TestUtils.java
public static File createTempDir(File parent, String name) { File file = new File(parent, name); file.deleteOnExit();/*from w w w . j a v a2s . com*/ file.mkdir(); return file; }
From source file:Main.java
public static void unZip(String zipFile, String outputFolder) { byte[] buffer = new byte[BUFFER_SIZE]; try {//ww w . j a v a 2 s . c o m File folder = new File(outputFolder); if (!folder.exists()) { folder.mkdir(); } ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFolder + File.separator + fileName); System.out.println("file unzip : " + newFile.getAbsoluteFile()); if (ze.isDirectory()) { newFile.mkdirs(); } else { FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.close(); } ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); System.out.println("Done"); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
/** * Copy database files to the given folder. Useful for debugging. * * @param folder the directory to copy files into *//*from w w w. jav a 2 s .co m*/ public static void copyDatabases(Context context, String folder) { File folderFile = new File(folder); if (!folderFile.exists()) { folderFile.mkdir(); } for (String db : context.databaseList()) { File dbFile = context.getDatabasePath(db); try { copyFile(dbFile, new File(folderFile.getAbsolutePath() + File.separator + db)); } catch (Exception e) { Log.e("ERROR", "ERROR COPYING DB " + db, e); } } }