I just wondered if my object of FileOutputStream
; out.close();
should be called in the catch block? Because the out object is still "open" in case of something happends.
If not, should anything else with the FileOutputStream
object be handled in the catch block?
public void saveBitmap(){
final File myDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), folderName);
myDir.mkdirs();
final File file = new File(myDir, getFileName() + getFileExtension());
FileOutputStream out = null;
try {
out = new FileOutputStream(file);
viewToBitmap().compress(Bitmap.CompressFormat.JPEG, quality, out);
}
out.flush();
out.getFD().sync();
out.close();
} catch (IOException e) {
//should I out.close(); here too?
e.printStackTrace();
onBitmapSavedListener(false, null);
}
}