Code example for FileOutputStream

Methods: close, flush

0
			File directory = new File(Environment.getExternalStorageDirectory() + "/Robotium-Screenshots/");
			directory.mkdir();
 
			File fileToSave = new File(directory,fileName);
			try { 
				fos = new FileOutputStream(fileToSave);
				if (b.compress(Bitmap.CompressFormat.JPEG, quality, fos) == false)
					Log.d(LOG_TAG, "Compress/Write failed");
				fos.flush();
				fos.close();
			} catch (Exception e) {
				Log.d(LOG_TAG, "Can't save the screenshot! Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.");
				e.printStackTrace();
			} 
		} 
	} 
}