Switching to use try-with-resources
The Closeables.closeQuietly(Closeable) method is no longer
present in v18. This change replaces usages with the
try-with-resource pattern.
This is part of the work to upgrade Guava to version 18.
Cherry-picked from commit dfff82913ea4201ecd983d40899e8459593f4495
BUG: 19672715
Change-Id: Id924d5db9e49c509e9a83c374411846305d23729
diff --git a/src/com/android/providers/contacts/debug/DataExporter.java b/src/com/android/providers/contacts/debug/DataExporter.java
index c7c7dea..3ea49bd 100644
--- a/src/com/android/providers/contacts/debug/DataExporter.java
+++ b/src/com/android/providers/contacts/debug/DataExporter.java
@@ -17,7 +17,6 @@
package com.android.providers.contacts.debug;
import com.android.providers.contacts.util.Hex;
-import com.google.common.io.Closeables;
import android.content.Context;
import android.net.Uri;
@@ -62,12 +61,10 @@
Log.i(TAG, "Dump started...");
ensureOutputDirectory(context);
- final ZipOutputStream os = new ZipOutputStream(new FileOutputStream(outFile));
- os.setLevel(Deflater.BEST_COMPRESSION);
- try {
+
+ try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(outFile))) {
+ os.setLevel(Deflater.BEST_COMPRESSION);
addDirectory(context, os, context.getFilesDir().getParentFile(), "contacts-files");
- } finally {
- Closeables.closeQuietly(os);
}
Log.i(TAG, "Dump finished.");
return DumpFileProvider.AUTHORITY_URI.buildUpon().appendPath(fileName).build();