Logger -> ErrorReporter
This commit is contained in:
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user