Contents 1 2 Serializable 3 Externalizable 4 Serializable
Contents 1. 객체 직렬화 2. Serializable 3. Externalizable 4. 왜 Serializable / Externalizable 인가? 5. Android 객체 직렬화 6. 원격절차호출 (RPC, Remote Procedure Call)란?
1 -1 기본 개념 Class Student 파일. txt String Id, Name, Grade; getserial. Data(); to. String(); Class Deserial. Stream Class Serial. Stream File. Read fr; File. Write fw; get. Deserial. Obj(); save. Object(Student s); close. Buffer();
1 -2 직렬화 방법 § 직렬화 인터페이스 § Serializable 인터페이스 - public interface Serializable { //. . . } § Exteranalizable 인터페이스 - public interface Externalizable extends Serializable { public void write. External(Object. Output out) throws IOException; public void read. External(Object. Input in) throws IOException, Class. Not. Found. Exception; }
2. Serializable ▣ 객체 직렬화(Serialization) ◈ Student so = new Student(); //직렬화 객체의 생성 ◈ File. Outuput. Stream fos = new File. Output. Stream("serialobject. dat"); //파일 스트림 생성 ◈ Object. Output. Stream oos = new Object. Output. Stream(fos); //객체 스트림으로 변환 ◈ oos. write. Object(so); //객체 저장 ◈ oos. close(); //스트림 닫기 ▣ 객체 역직렬화(Deserialization) ◈ File. Input. Stream fis = new File. Input. Stream("serialobject. dat"); //파일 스트림 생성 ◈ Object. Input. Stream ois = new Object. Input. Stream(fis); //객체 스트림으로 변환 ◈ Object obj = ois. read. Object(); //객체 읽기 ◈ Student temp = (Student)obj; //형복원 ◈ ois. close(); //스트림 닫기
3. Externalizable ▣ 객체 직렬화(Externalizable) ◈ Student 2 so = new Student 2(); //직렬화 객체의 생성 ◈ File. Outuput. Stream fos = new File. Output. Stream("serialobject. dat"); //파일 스트림 생성 ◈ Object. Output. Stream oos = new Object. Output. Stream(fos); //객체 스트림으로 변환 ◈ oos. write. Object(so); //객체 저장 ◈ oos. close(); //스트림 닫기 ▣ 객체 역직렬화(Deserialization) ◈ File. Input. Stream fis = new File. Input. Stream("serialobject. dat"); //파일 스트림 생성 ◈ Object. Input. Stream ois = new Object. Input. Stream(fis); //객체 스트림으로 변환 ◈ Object obj = ois. read. Object(); //객체 읽기 ◈ Student 2 temp = (Student 2)obj; //형복원 ◈ ois. close(); //스트림 닫기
6. 원격절차호출 (RPC, Remote Procedure Call)란? RPC RMI 자바전용 RPC DCOM MS전용 RPC CORBA 모든언어에적용 되는 RPC IPC 안드로이드용 RPC …. .
THANK YOU
- Slides: 13