aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/files/LocalStorage.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-05-11 08:56:34 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-05-11 09:34:58 +0200
commitaea41c86f05d11828120fa71c0bcb5b1756061f1 (patch)
treeb2bb0ee0c681a838e1c22eb61885e2c1a5ca715e /main/src/cgeo/geocaching/files/LocalStorage.java
parentf3b65c3221d96bd431000b71bc8fb29a81c0eab9 (diff)
downloadcgeo-aea41c86f05d11828120fa71c0bcb5b1756061f1.zip
cgeo-aea41c86f05d11828120fa71c0bcb5b1756061f1.tar.gz
cgeo-aea41c86f05d11828120fa71c0bcb5b1756061f1.tar.bz2
#1348: use buffered io
Diffstat (limited to 'main/src/cgeo/geocaching/files/LocalStorage.java')
-rw-r--r--main/src/cgeo/geocaching/files/LocalStorage.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/main/src/cgeo/geocaching/files/LocalStorage.java b/main/src/cgeo/geocaching/files/LocalStorage.java
index f59f15c..0f3e0e1 100644
--- a/main/src/cgeo/geocaching/files/LocalStorage.java
+++ b/main/src/cgeo/geocaching/files/LocalStorage.java
@@ -2,14 +2,18 @@ package cgeo.geocaching.files;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.utils.CryptUtils;
+import cgeo.geocaching.utils.IOUtils;
import cgeo.geocaching.utils.Log;
import ch.boye.httpclientandroidlib.Header;
import ch.boye.httpclientandroidlib.HttpResponse;
+
import org.apache.commons.lang3.StringUtils;
import android.os.Environment;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -275,19 +279,14 @@ public class LocalStorage {
destination.getParentFile().mkdirs();
InputStream input = null;
- OutputStream output;
+ OutputStream output = null;
try {
- input = new FileInputStream(source);
- output = new FileOutputStream(destination);
+ input = new BufferedInputStream(new FileInputStream(source));
+ output = new BufferedOutputStream(new FileOutputStream(destination));
} catch (FileNotFoundException e) {
Log.e("LocalStorage.copy: could not open file", e);
- if (input != null) {
- try {
- input.close();
- } catch (IOException e1) {
- // ignore
- }
- }
+ IOUtils.closeQuietly(input);
+ IOUtils.closeQuietly(output);
return false;
}