java读取和保存对象

Posted by Vincent on Saturday, January 14, 2006

有这个东西,做缓存就很方便了

Map map = new HashMap();
FileOutputStream fos = new FileOutputStream("d:\\111.conf");
ObjectOutputStream o = new ObjectOutputStream(fos);
o.writeObject(map);
fos.close();
o.close();
FileInputStream fis = new FileInputStream(new File("d:\\111.conf"));
ObjectInputStream ois = new ObjectInputStream(fis);
Map map = (Map)ois.readObject();
System.out.println(map.size());
fis.close();
ois.close();

「真诚赞赏,手留余香」

我的乐与怒

真诚赞赏,手留余香

使用微信扫描二维码完成支付