package m.util;
import java.io.*;
public class Serialization {
public static void serialize(Serializable obj, String pathname) {
File77.createNotExistingDirs(pathname);
ObjectOutputStream s=null;
try {
s=new ObjectOutputStream(new FileOutputStream(pathname));
s.writeObject(obj);
s.flush();
s.close();
} catch(Exception e) {
try {
s.close();
} catch(Exception ignored) {}
U77.throwException(e);
}
}
/**
* on error throws RuntimeException
*/
public static Object deserialize(File file) {
return deserialize(file.getAbsolutePath());
}
/**
* on error throws RuntimeException
*/
public static Object deserialize(String pathname) {
ObjectInputStream s=null;
try {
s=new ObjectInputStream(new FileInputStream(pathname));
Object o=s.readObject();
s.close();
return o;
} catch(Exception e) {
try {
s.close();
} catch(Exception ignored) {}
U77.throwException(e);
/* heh */
return null;
}
}
}
From the Battery http://btrgame.com/dev/srconline.jsp#m.util