import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class MainClass {
public static void main(String[] args) throws Exception {
ObjectOutput out = new ObjectOutputStream(new FileOutputStream("X.file"));
MyClass zorcon = new MyClass();
out.writeObject(zorcon);
ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File("X.file")));
Object mystery = in.readObject();
System.out.println(mystery.getClass());
}
}
// A serializable class.
class MyClass implements Serializable {
}
|