Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4dda2b8 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Switching to use try-with-resources"

parents 5f35f34f 6f0b0802
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -148,13 +148,9 @@ public class ContactPhotoUtils {
     */
    public static boolean savePhotoFromUriToUri(Context context, Uri inputUri, Uri outputUri,
            boolean deleteAfterSave) {
        FileOutputStream outputStream = null;
        InputStream inputStream = null;
        try {
            outputStream = context.getContentResolver()
        try (FileOutputStream outputStream = context.getContentResolver()
                 .openAssetFileDescriptor(outputUri, "rw").createOutputStream();
            inputStream = context.getContentResolver().openInputStream(
                    inputUri);
             InputStream inputStream = context.getContentResolver().openInputStream(inputUri)) {

            final byte[] buffer = new byte[16 * 1024];
            int length;
@@ -168,8 +164,6 @@ public class ContactPhotoUtils {
            Log.e(TAG, "Failed to write photo: " + inputUri.toString() + " because: " + e);
            return false;
        } finally {
            Closeables.closeQuietly(inputStream);
            Closeables.closeQuietly(outputStream);
            if (deleteAfterSave) {
                context.getContentResolver().delete(inputUri, null, null);
            }