[Android] Logcat: catch FileNotFoundException too
Jean-Baptiste Kempf
git at videolan.org
Fri Jul 18 22:33:20 CEST 2014
vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Jul 18 22:33:01 2014 +0200| [c251827bc98f2ee2c08d01a595fa63d1c4f59387] | committer: Jean-Baptiste Kempf
Logcat: catch FileNotFoundException too
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c251827bc98f2ee2c08d01a595fa63d1c4f59387
---
vlc-android/src/org/videolan/vlc/util/Logcat.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/Logcat.java b/vlc-android/src/org/videolan/vlc/util/Logcat.java
index 77e3cb4..c9552b8 100644
--- a/vlc-android/src/org/videolan/vlc/util/Logcat.java
+++ b/vlc-android/src/org/videolan/vlc/util/Logcat.java
@@ -22,6 +22,7 @@ package org.videolan.vlc.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -40,15 +41,22 @@ public class Logcat {
String[] args = { "logcat", "-v", "time", "-d" };
Process process = Runtime.getRuntime().exec(args);
- InputStreamReader input = new InputStreamReader(
- process.getInputStream());
- OutputStreamWriter output = new OutputStreamWriter(
- new FileOutputStream(filename));
+
+ InputStreamReader input = new InputStreamReader(process.getInputStream());
+
+ FileOutputStream fileStream;
+ try {
+ fileStream = new FileOutputStream(filename);
+ } catch( FileNotFoundException e) {
+ return;
+ }
+
+ OutputStreamWriter output = new OutputStreamWriter(fileStream);
BufferedReader br = new BufferedReader(input);
BufferedWriter bw = new BufferedWriter(output);
- String line;
try {
+ String line;
while ((line = br.readLine()) != null) {
bw.write(line);
bw.newLine();
More information about the Android
mailing list