diff options
author | ByteHamster <info@bytehamster.com> | 2018-01-07 20:17:18 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2018-01-07 20:17:18 +0100 |
commit | 12456b52def840fcfdf35e50cf376f2d79d7c8ba (patch) | |
tree | 1751826c072911ff761bc680d136b8a8e0355fdf | |
parent | 4c00f764943580e928feb4851d3fdc68594613dc (diff) | |
download | AntennaPod-12456b52def840fcfdf35e50cf376f2d79d7c8ba.zip |
Using FileUtils.copyInputStreamToFile
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java index 7e63ae1a6..01fcfe83d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/ImportExportActivity.java @@ -16,6 +16,7 @@ import android.view.MenuItem; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.PodDBAdapter; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import java.io.File; @@ -23,7 +24,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.nio.channels.FileChannel; /** @@ -109,7 +109,7 @@ public class ImportExportActivity extends AppCompatActivity { InputStream inputStream = null; try { inputStream = getContentResolver().openInputStream(inputUri); - copyInputStreamToFile(inputStream, currentDB); + FileUtils.copyInputStreamToFile(inputStream, currentDB); displayImportSuccessDialog(); } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e)); @@ -132,23 +132,6 @@ public class ImportExportActivity extends AppCompatActivity { d.show(); } - private void copyInputStreamToFile(InputStream in, File file) { - OutputStream out = null; - try { - out = new FileOutputStream(file); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0){ - out.write(buf, 0, len); - } - } catch (IOException e) { - Log.e(TAG, Log.getStackTraceString(e)); - Snackbar.make(findViewById(R.id.import_export_layout), e.getLocalizedMessage(), Snackbar.LENGTH_SHORT).show(); - } finally { - IOUtils.closeQuietly(out); - } - } - private void backupToDocument(Uri uri) { ParcelFileDescriptor pfd = null; FileOutputStream fileOutputStream = null; |