1.首先给出序列化与反序列化工具类
public class SerializableInterface {
public SerializableInterface(){
}
public static byte[] serialize(HashMap<String, String> hashMap){
try {
ByteArrayOutputStream mem_out = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(mem_out);
out.writeObject(hashMap);
out.close();
mem_out.close();
byte[] bytes = mem_out.toByteArray();
return bytes;
} catch (IOException e) {
return null;
}
}
public static HashMap<String, String> deserialize(byte[] bytes){
try {
ByteArrayInputStream mem_in = new ByteArrayInputStream(bytes);
ObjectInputStream in = new ObjectInputStream(mem_in);
HashMap<String, String> hashMap = (HashMap<String, String>)in.readObject();
in.close();
mem_in.close();
return hashMap;
} catch (StreamCorruptedException e) {
r