Java tutorial
//package com.java2s; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; public class Main { public static boolean OutPutImage(File file, Bitmap bitmap) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } BufferedOutputStream bos = null; FileOutputStream fos = null; try { fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); if (bos != null) { bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos); bos.flush(); fos.flush(); return true; } else { return false; } } catch (IOException e) { return false; } finally { if (bos != null) { try { bos.close(); } catch (IOException e) { e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } }