History
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package org.solovyev.android.io;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -10,14 +8,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
abstract class BaseFileLoader {
|
||||
|
||||
@NonNull
|
||||
protected final Context context;
|
||||
|
||||
public BaseFileLoader(@NonNull Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
public abstract class BaseIoLoader {
|
||||
|
||||
@Nullable
|
||||
public CharSequence load() {
|
@@ -8,12 +8,12 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
public abstract class BaseFileSaver implements Runnable {
|
||||
public abstract class BaseIoSaver implements Runnable {
|
||||
|
||||
@NonNull
|
||||
private final CharSequence data;
|
||||
|
||||
protected BaseFileSaver(@NonNull CharSequence data) {
|
||||
protected BaseIoSaver(@NonNull CharSequence data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
31
app/src/main/java/org/solovyev/android/io/FileLoader.java
Normal file
31
app/src/main/java/org/solovyev/android/io/FileLoader.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.solovyev.android.io;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class FileLoader extends BaseIoLoader {
|
||||
|
||||
@NonNull
|
||||
private final File file;
|
||||
|
||||
public FileLoader(@NonNull File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CharSequence load(@NonNull File file) {
|
||||
final FileLoader loader = new FileLoader(file);
|
||||
return loader.load();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
public class FileSaver extends BaseFileSaver {
|
||||
public class FileSaver extends BaseIoSaver {
|
||||
|
||||
@NonNull
|
||||
private final File file;
|
||||
|
Reference in New Issue
Block a user