0
사용자 지정 serialization을 테스트하려고하는데 readObject()
메서드가 호출되지 않습니다. writeObject 메서드를 호출 할 수는 있지만. readObject 메소드()를 오버로드 할 수 있습니까?readObject 메서드가 호출되지 않습니다.
public class Test {
String pwd1 ;
public static void main(String arg[]) throws IOException, ClassNotFoundException{
FileInputStream fis = new FileInputStream("//vhub.lmera.ericsson.se//home//xsinkus//WDP//Desktop2k8R2//COMP_DOCS//Test//kusha1.ser");
@SuppressWarnings("resource")
ObjectInputStream ois = new ObjectInputStream(fis);
System.out.println("I am being called ");
SerilizationTest si = (SerilizationTest)ois.readObject();
System.out.println("After called ");
System.out.println(si.name);
System.out.println(si.pwd);
//si.readObject();
}
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException {
ois.defaultReadObject();
pwd1 = (String) ois.readObject();
System.out.println("I am in ");
}
}
은 '테스트'가 직렬화 가능하다고 가정됩니까? – Moira
'TestInput' 인스턴스가 아니라'ObjectInputStream'의 인스턴스에서'readObject()'를 호출한다는 것을 알았습니까? – Thomas
@Thomas'ObjectInputStream'은'Serializable' 객체의 private'readObject' 메소드를 사용합니다. [또 다른 관련 질문] (http://stackoverflow.com/questions/12963445/serialization-readobject-writeobject-overides). – Moira