List of usage examples for java.io ByteArrayOutputStream ByteArrayOutputStream
public ByteArrayOutputStream()
From source file:Main.java
public static File saveBitmap2file(Bitmap bmp) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArray = stream.toByteArray(); File imageFile = null;/* ww w. j a v a 2 s. c om*/ try { imageFile = File.createTempFile("tempImage" + System.currentTimeMillis(), ".png"); } catch (IOException e) { e.printStackTrace(); } FileOutputStream fstream = null; try { fstream = new FileOutputStream(imageFile); BufferedOutputStream bStream = new BufferedOutputStream(fstream); bStream.write(byteArray); if (bStream != null) { bStream.close(); } } catch (IOException e) { e.printStackTrace(); } return imageFile; }