30 lines
773 B
Java
30 lines
773 B
Java
package infrastructure;
|
|
|
|
import java.io.*;
|
|
|
|
public class Persistenz {
|
|
private static final String FACTORY_DATA = "Factory.ser";
|
|
public static boolean existsSavedData(String name){
|
|
return new File(name + FACTORY_DATA).exists();
|
|
}
|
|
|
|
public static void saveFactoryData(Object Factory, String name){
|
|
try{
|
|
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(name + FACTORY_DATA));
|
|
oos.writeObject(Factory);
|
|
oos.close();
|
|
}catch(Exception e){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static Object loadFactoryData(String name) throws Exception{
|
|
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(name + FACTORY_DATA));
|
|
Object fac = ois.readObject();
|
|
ois.close();
|
|
return fac;
|
|
}
|
|
|
|
}
|