mirror of
https://github.com/nextcloud/android.git
synced 2024-12-01 03:43:43 +03:00
providers: Close and flush FileOutputStream using try-with-resources to avoid memleak.
This commit is contained in:
parent
f3e736f50a
commit
7c28ca2022
1 changed files with 2 additions and 6 deletions
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue