History tests

This commit is contained in:
serso
2016-02-23 17:23:54 +01:00
parent cff8a24885
commit b83d5f68e9
7 changed files with 246 additions and 55 deletions

View File

@@ -0,0 +1,42 @@
package org.solovyev.android.io;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.solovyev.android.calculator.ErrorReporter;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class FileSystem {
@Inject
ErrorReporter errorReporter;
@Inject
public FileSystem() {
}
public boolean writeSilently(@NonNull File file, @NonNull String data) {
try {
write(file, data);
return true;
} catch (IOException e) {
errorReporter.onException(e);
}
return false;
}
public void write(@NonNull File file, @NonNull String data) throws IOException {
FileSaver.save(file, data);
}
@Nullable
public CharSequence read(File file) throws IOException {
return FileLoader.load(file);
}
}