시소당
import java.io.*;
class Employee implements Serializable {
public String name;
public int id;
public Employee(String name, int id){
this.name = name;
this.id = id;
}
}
public class Test {
public static void main(String[] args) throws Exception {
//메모리에 있는 객체를 하드디스크에 저장하거나
// 네트워크에 있는 다른 컴퓨터로 전달하는 그런거래요 이클래스가
Employee e = new Employee("홍길동", 100);
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("emp.obj"));
os.writeObject(e);
os.close();
//////////객체 직렬화 끝/////////////
ObjectInputStream is = new ObjectInputStream(new FileInputStream("emp.obj"));
Employee e2 = (Employee)is.readObject();
System.out.println(e2+e2.name+", "+e2.id);
is.close();
}
}
출처 6/18 Serializable |작성자 네이아
http://blog.naver.com/akswnsjd1?Redirect=Log&logNo=60035696037