序列化问题

public void testserialAndDesirial() throws Exception { Magazine magazine = new Magazine(); magazine.setName("1111testfucku"); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream( "magazie")); out.writeObject(magazine); out.close(); } public void testGetSer() throws Exception { ObjectInputStream in = new ObjectInputStream(new FileInputStream( "magazie")); Magazine magazine2 = (Magazine) in.readObject(); in.close(); System.out.println(magazine2.getName()); }  

package cn.ac.ict.core; import java.io.Serializable; public class Magazine implements Serializable { /** * */ private static final long serialVersionUID = -8749813542960830808L; private String name; private String version; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getVersion() { return version; } }  

你可能感兴趣的:(JAVA)