List of usage examples for java.io FileOutputStream flush
public void flush() throws IOException
From source file:Main.java
public static String saveImg(Bitmap b, String name) throws Exception { String path = Environment.getExternalStorageDirectory().getPath() + File.separator + "QuCai/shareImg/"; File mediaFile = new File(path + File.separator + name + ".jpg"); if (mediaFile.exists()) { mediaFile.delete();/* w w w .j a v a2s . c o m*/ } if (!new File(path).exists()) { new File(path).mkdirs(); } mediaFile.createNewFile(); FileOutputStream fos = new FileOutputStream(mediaFile); b.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); b.recycle(); b = null; System.gc(); return mediaFile.getPath(); }
From source file:Main.java
public static void savePNG_After(Bitmap bitmap, String name) { File file = new File(name); try {// w w w.j av a 2 s . com FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveJPGE_After(Bitmap bitmap, String path) { File file = new File(path); try {//from ww w . j a va 2 s. co m FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveBitmapToSD(Bitmap bitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/Download"); myDir.mkdirs();/*from w w w. j a v a2 s.c om*/ Random generator = new Random(); String fname = "Image-" + System.currentTimeMillis() + ".jpg"; File file = new File(myDir, fname); if (file.exists()) file.delete(); try { FileOutputStream out = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static boolean save_png_from_bitmap(Bitmap bm, String filename) { boolean resultado = true; File f = new File(filename); if (f.exists()) f.delete();//from w w w .java2 s.c o m try { FileOutputStream o_s = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.PNG, 100, o_s); o_s.flush(); o_s.close(); } catch (Exception e) { resultado = false; e.printStackTrace(); } return resultado; }
From source file:Main.java
public static void saveJPGE_After(Context context, Bitmap bitmap, String path) { File file = new File(context.getExternalCacheDir() + path); try {//from ww w . j a va 2s . c o m FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveThePicture(Bitmap bitmap, String p) throws Exception { File file = new File(p); FileOutputStream fos = new FileOutputStream(file); // bitmap./*ww w.ja v a 2 s .com*/ if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos)) { fos.flush(); fos.close(); } }
From source file:Main.java
public static void saveImage(Bitmap bmp) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/abcxyz"); myDir.mkdirs();//from w w w. ja v a 2s . co m Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String name = "Image-" + n + ".jpg"; File file = new File(myDir, name); if (file.exists()) file.delete(); try { FileOutputStream out = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static File convertBase64IntoFile(String base64, String path) { File dwldsPath = new File(path); byte[] pdfAsBytes = convertBase64IntoByte(base64); FileOutputStream os; try {//ww w . j a va 2 s. c om os = new FileOutputStream(dwldsPath, false); os.write(pdfAsBytes); os.flush(); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return dwldsPath; }
From source file:Main.java
public static void saveBitmap(Bitmap bm, String picName) { try {//from w ww .j a v a 2 s . com if (!isFileExist("")) { File tempf = createSDDir(""); } File f = new File(SDPATH, picName + ".JPEG"); if (f.exists()) { f.delete(); } FileOutputStream out = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }