List of usage examples for java.io File createNewFile
public boolean createNewFile() throws IOException
From source file:Main.java
public static File createSDFile(String fileName) { File file = new File(SDPATH + fileName); try {/* w ww. java 2 s . c o m*/ file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } return file; }
From source file:Main.java
public static void saveMyBitmap3(String bitName, Bitmap mBitmap) throws IOException { String myJpgPath = Environment.getExternalStorageDirectory() + "/pepper/" + "3.png"; File tmp = new File("/sdcard/pepper/"); if (!tmp.exists()) { tmp.mkdir();/* w w w . j a va 2 s . c o m*/ } File f = new File(myJpgPath); f.createNewFile(); FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); try { fOut.flush(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveMyBitmap2(String bitName, Bitmap mBitmap) throws IOException { String myJpgPath = Environment.getExternalStorageDirectory() + "/pepper/" + "2.png"; File tmp = new File("/sdcard/pepper/"); if (!tmp.exists()) { tmp.mkdir();/* ww w .j a v a 2 s . com*/ } File f = new File(myJpgPath); f.createNewFile(); FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); try { fOut.flush(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveMyBitmap(String bitName, Bitmap mBitmap) throws IOException { String myJpgPath = Environment.getExternalStorageDirectory() + "/pepper/" + "1.png"; File tmp = new File("/sdcard/pepper/"); if (!tmp.exists()) { tmp.mkdir();/* w w w. j a v a 2s. c o m*/ } File f = new File(myJpgPath); f.createNewFile(); FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); try { fOut.flush(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void mkFile(String filePath, boolean mkdir) throws Exception { File file = new File(filePath); file.getParentFile().mkdirs();//from ww w.ja va 2 s. co m file.createNewFile(); file = null; }
From source file:Main.java
public static boolean createNoMedia(File dir) { File noMedia = new File(dir, NO_MEDIA); try {/*ww w.j ava 2 s . c o m*/ return noMedia.createNewFile(); } catch (IOException e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static void saveToFile(Bitmap bmp, String filePath) throws IOException { File file = new File(filePath); if (!file.exists()) { file.createNewFile(); }//from w ww .j a v a 2 s .c o m FileOutputStream fout = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.JPEG, 100, fout); fout.close(); }
From source file:Main.java
public static void createNoMedia() { //Create .nomedia in audio folder File dir = new File(Environment.getExternalStorageDirectory() + "/FranqInterface/audio"); File nomediaFile = new File(dir, ".nomedia"); try {//from ww w. j av a2s . c o m nomediaFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void makeNoMediaFile(File dir) { try {/*from ww w .j a v a 2 s.com*/ File f = new File(dir, ".nomedia"); if (!f.exists()) { f.createNewFile(); } } catch (Exception e) { } }
From source file:Main.java
public static void saveThumbnail(String filePath, Bitmap bitmap) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes); // you can create a new file name "test.jpg" in sdcard folder. File f = new File(filePath); try {//w w w.j a va2 s . c o m f.createNewFile(); // write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); } catch (IOException e) { e.printStackTrace(); } }