Code example for FileOutputStream

Methods: closeflush

0
	public void saveFile(Bitmap bitmap) {
		String path = Environment.getExternalStorageDirectory().toString();
		OutputStream fOut = null;
		File file = new File(path, "screenshot" + ".png");
		try { 
			fOut = new FileOutputStream(file);
 
			bitmap.compress(Bitmap.CompressFormat.PNG, 90, fOut);
			fOut.flush();
			fOut.close();
 
			MediaStore.Images.Media.insertImage(getContentResolver(),
					file.getAbsolutePath(), file.getName(), file.getName());
 
		} catch (Exception e) {
			e.printStackTrace();
		} 
 
	} 
 
Connect your IDE to all the code out there  Get Codota for Java