This commit is contained in:
serso
2016-01-12 10:49:50 +01:00
parent a57d4aab57
commit 6d91013858
26 changed files with 417 additions and 266 deletions

View File

@@ -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() {

View File

@@ -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;
}

View 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);
}
}

View 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;