标签:数组 hashmap cto write object null cat byte out
把Map转换成byte数组,使用 ByteArrayOutputStream和ObjectOutputStream
Map<String,String> map = new HashMap<String,String>();
map.put("name","aaa");
map.put("age","11");
try {
byte[] bt = null;
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(map);
bt=os.toByteArray();
oos.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
标签:数组 hashmap cto write object null cat byte out
原文地址:http://www.cnblogs.com/dayuss/p/7201911.html