private static final long serialVersionUID = -32312312321354L;
private final static ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("x1",Double.TYPE),
new ObjectStreamField("y1", Double.class),
new ObjectStreamField("x2",Double.TYPE),
new ObjectStreamField("y2", Double.class)
};
private transient double x,y,width, height;
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
ObjectInputStream.GetField fields;
fields = in.readFields();
x = fields.get("x1", 0.0);
y = fields.get("y1",0.0);
double x2 = fields.get("x2", 0.0);
double y2 = fields.get("y2",0.0);
width = x2-x;
height = y2-y;
}
private void writeObject(ObjectOutputStream out) throws IOException{
ObjectOutputStream.PutField fields;
fields = out.putFields();
fields.put("x1", x);
fields.put("y1", y);
fields.put("x2", x+width);
fields.put("y2", y+height);
out.writeFields();
}
결론
가상의 변수이름을 지정하여 넘겨주고 받을 때는 가상의 이름으로 받아서, 직렬화되지 않는 변수에 그 값을 넣어준다.
결론
가상의 변수이름을 지정하여 넘겨주고 받을 때는 가상의 이름으로 받아서, 직렬화되지 않는 변수에 그 값을 넣어준다.
'JAVA이야기' 카테고리의 다른 글
IBM의 JIT Compiler (0) | 2011.08.21 |
---|---|
Execution Engine (0) | 2011.08.21 |
맞춤화된 직렬화 (0) | 2011.08.07 |
직렬화 가능한 클래스 만들기 (0) | 2011.07.30 |
객체 직렬화 (1) | 2011.07.30 |