Logger -> ErrorReporter

This commit is contained in:
serso
2016-01-14 16:03:57 +01:00
parent e015a12718
commit 91a8a1122b
26 changed files with 240 additions and 274 deletions

View File

@@ -1,7 +1,6 @@
package org.solovyev.android.io;
import android.support.annotation.Nullable;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
@@ -11,7 +10,7 @@ import java.io.InputStreamReader;
public abstract class BaseIoLoader {
@Nullable
public CharSequence load() {
public CharSequence load() throws IOException {
BufferedReader reader = null;
try {
final InputStream is = getInputStream();
@@ -26,12 +25,9 @@ public abstract class BaseIoLoader {
line = reader.readLine();
}
return result;
} catch (IOException e) {
Log.e(getClass().getSimpleName(), e.getMessage(), e);
} finally {
Io.close(reader);
}
return null;
}
@Nullable

View File

@@ -1,14 +1,13 @@
package org.solovyev.android.io;
import android.support.annotation.NonNull;
import android.util.Log;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
public abstract class BaseIoSaver implements Runnable {
public abstract class BaseIoSaver {
@NonNull
private final CharSequence data;
@@ -17,13 +16,11 @@ public abstract class BaseIoSaver implements Runnable {
this.data = data;
}
public void save() {
public void save() throws IOException {
OutputStreamWriter out = null;
try {
out = new OutputStreamWriter(getOutputStream());
out.write(data.toString());
} catch (IOException e) {
Log.e("FileSaver", e.getMessage(), e);
} finally {
Io.close(out);
}
@@ -31,9 +28,4 @@ public abstract class BaseIoSaver implements Runnable {
@NonNull
protected abstract FileOutputStream getOutputStream() throws FileNotFoundException;
@Override
public void run() {
save();
}
}

View File

@@ -18,7 +18,7 @@ public class FileLoader extends BaseIoLoader {
}
@Nullable
public static CharSequence load(@NonNull File file) {
public static CharSequence load(@NonNull File file) throws IOException {
final FileLoader loader = new FileLoader(file);
return loader.load();
}

View File

@@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileSaver extends BaseIoSaver {
@@ -16,7 +17,7 @@ public class FileSaver extends BaseIoSaver {
this.file = file;
}
public static void save(@NonNull File file, @NonNull CharSequence data) {
public static void save(@NonNull File file, @NonNull CharSequence data) throws IOException {
final FileSaver fileSaver = new FileSaver(file, data);
fileSaver.save();
}