ObjectOutputStreamout=null;try{out=newObjectOutputStream(newFileOutputStream("D:/file/project"));for(Map.Entry>entry:map.entrySet()){Integernum2=entry...
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(
new FileOutputStream("D:/file/project"));
for(Map.Entry> entry:map.entrySet()){
Integer num2 = entry.getKey();
out.writeInt(num2);
List list = entry.getValue();
for(Iterator it = list.iterator();it.hasNext();){
Goods goods = it.next();
out.writeObject(goods);
}
}
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally{
if(out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
如何反序列化啊!跪求!
public class Goods implements Serializable{
private String goodsCode;
private String goodsName;
private double price;
public Goods(){}
public Goods(String goodsCode,String goodsName,double price){
this.goodsCode = goodsCode;
this.goodsName = goodsName;
this.price = price;
}
Goods类这些属性,还有一些没复制,反序列化,怎么读出来map的键和值?
展开