本帖最后由 王博 于 2012-12-25 13:53 编辑
import java.io.*; import java.util.*; class UnSerializaDate { Date d = null; UnSerializaDate() { try { FileInputStream f = new FileInputStream("date.ser"); //ObjectInputStream s = new ObjectInputStream(f); //这俩步具体是什么意思啊?我直接调用f的read()也能读出来啊 //d = (Date)s.readObject(); //为什么要写这两步啊 f.read(); f.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { UnSerializaDate a = new UnSerializaDate(); System.out.println("the date read is:"+a.d); } } |