88import java.io.PrintWriter;
99import java.io.StringWriter;
1010import java.lang.reflect.InvocationTargetException;
11- import android.content.Context;
1211
1312public class FileUtils {
14- private static Context context;
15- public FileUtils(Context ctx) {
16- context = ctx;
17- }
1813 public static String getStackTraceAsString(Throwable th) {
1914 StringWriter sw = new StringWriter();
2015 PrintWriter pw = new PrintWriter(sw);
@@ -23,13 +18,10 @@ public static String getStackTraceAsString(Throwable th) {
2318 }
2419 public static void copyFile(String from, String to) {
2520 try {
26- Files.copy(Paths.get(from), Paths.get(to), StandardCopyOption.REPLACE_EXISTING);
21+ Files.copy(Paths.get(from), Paths.get(to), StandardCopyOption.REPLACE_EXISTING);
2722 } catch (Exception e) {
28- Throwable real = (e instanceof InvocationTargetException)
29- ? ((InvocationTargetException) e).getCause()
30- : e;
23+ Throwable real = (e instanceof InvocationTargetException) ? ((InvocationTargetException) e).getCause() : e;
3124 String errorLog = getStackTraceAsString(real);
32- Toast.makeText(context, errorLog, Toast.LENGTH_LONG).show();
3325 Logger.get().error("Error!: " + errorLog);
3426 }
3527 }
@@ -56,12 +48,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
5648 }
5749 });
5850 } catch (Exception e) {
59- Throwable real = (e instanceof InvocationTargetException)
60- ? ((InvocationTargetException) e).getCause()
61- : e;
51+ Throwable real = (e instanceof InvocationTargetException) ? ((InvocationTargetException) e).getCause() : e;
6252 String errorLog = getStackTraceAsString(real);
63- Toast.makeText(context, errorLog, Toast.LENGTH_LONG).show();
6453 Logger.get().error("Error!: " + errorLog);
65- }
54+ }
6655 }
6756}
0 commit comments