map如何轉(zhuǎn)成byte數(shù)組?
把Map轉(zhuǎn)換成byte數(shù)組,使用 byteArrayOutputStream 和 ObjectOutputStream
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
public static byte[] getSerializedBytes(Map<String, Double> list) {undefined
if (null == list || list.size() < 0)
return null;
try {undefined
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bo);
os.writeObject(list);
return bo.toByteArray();
} catch (IOException e) {undefined
return null;