providers: Close and flush FileOutputStream using try-with-resources to avoid memleak.

This commit is contained in:
eho 2018-03-27 09:53:32 +02:00
parent f3e736f50a
commit 7c28ca2022

View file

@ -89,15 +89,11 @@ public class DiskLruImageCacheFileProvider extends ContentProvider {
byte[] bitmapData = bos.toByteArray();
//write the bytes in file
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
try (FileOutputStream fos = new FileOutputStream(f)){
fos.write(bitmapData);
} catch (FileNotFoundException e) {
Log_OC.e(TAG, "File not found: " + e.getMessage());
}
fos.write(bitmapData);
fos.flush();
fos.close();
} catch (Exception e) {
Log_OC.e(TAG, "Error opening file: " + e.getMessage());