You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

import java.io.*;
import java.util.Scanner;
public class Storage implements StorageInterface {
@Override
public void export() {
}
@Override
public void load() {
}
public boolean writeFile(String path, String content) {
if (!path.isEmpty() && !content.isEmpty()) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(path, false));
writer.append(content);
writer.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
return false;
}
public String readFile(String path) {
if (!path.isEmpty()) {
StringBuilder data = new StringBuilder();
try {
File f = new File(path);
Scanner myReader = new Scanner(f);
while (myReader.hasNextLine()) {
data.append(myReader.nextLine());
}
myReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
return data.toString();
}
return null;
}
}