2014년 3월 25일 화요일

자바AWT직렬화예제[자바교육잘하는곳/자바교육추천/자바학원추천/JAVA학원교육추천/JAVA교육학원추천/실무자바교육]

자바AWT직렬화예제[자바교육잘하는곳/자바교육추천/자바학원추천/JAVA학원교육추천/JAVA교육학원추천/실무자바교육]

package onj;

import java.awt.*;
import java.awt.event.*;
import java.io.*;

class AWTSerTest extends Frame {
TextArea view = new TextArea();

public AWTSerTest() {
add(view, "Center");
}

public static void main(String[] args) {
Frame f = null;
try {
FileInputStream inFile = new FileInputStream("AWTSerTest.ser");
ObjectInput in = new ObjectInputStream(inFile);
f = (Frame) in.readObject();
} catch (IOException ioe) {
f = new AWTSerTest();
f.setSize(500, 300);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
try {
FileOutputStream outFile = new FileOutputStream(
"AWTSerTest.ser");
ObjectOutput out = new ObjectOutputStream(outFile);
out.writeObject(we.getWindow());
out.close();
System.exit(0);
} catch (IOException e) {
e.printStackTrace();
}
}
});
f.setVisible(true);
}
}
 



댓글 없음:

댓글 쓰기