public static void main(String[] args) {
try {
Object input = ABC.ad;
ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(new File("test.enum")));
objectOutputStream.writeObject(input);
objectOutputStream.close();
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(new File("test.enum")));
Object outPut = objectInputStream.readObject();
objectInputStream.close();
if(input == outPut) {
System.out.println("Same ............"+input+" "+outPut);
}
} catch (Exception e) {
e.printStackTrace();
}
}
enum ABC {
ad,de;
}
我正在尝试序列化枚举和反序列化。正如所料,我得到了结果"相同"。但我不知道它是如何工作的。即使我也检查了Enum
课程。它没有readResovle
这样的方法。请解释..