This article is more than ten years old and potentially contains out-dated information.
작성한지 10년 이상 지난 게시물입니다. 최신의 정보와 맞지 않는 내용을 포함할 수도 있습니다.
Source Code
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Date;
public class Test
{
public static void main(String[] args) {
try {
FileOutputStream fos = new FileOutputStream("object");
ObjectOutput oo = new ObjectOutputStream(fos);
oo.writeDouble(12.128);
oo.writeObject("Today");
oo.writeObject(new Date());
oo.flush();
oo.close();
fos.flush();
fos.close();
FileInputStream fis = new FileInputStream("object");
ObjectInput oi = new ObjectInputStream(fis);
double d = oi.readDouble();
String str = (String)oi.readObject();
Date date = (Date)oi.readObject();
fis.close();
oi.close();
System.out.println(d);
System.out.println(str);
System.out.println(date.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
References