62,620
社区成员
发帖
与我相关
我的任务
分享 HashMap<String, String> map=new HashMap<String,String>();
map.put("name", "kwj");
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(map);
oout.flush();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
System.out.println(bin.available());
byte[] b = new byte[bin.available()];
bin.read(b);
HashMap<String, String> m1 = (HashMap<String, String>)(new ObjectInputStream(new ByteArrayInputStream(b)).readObject());
System.out.println(m1.get("name"));