com.founder.core.utils.SerializableUtil Maven / Gradle / Ivy
package com.founder.core.utils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.HashMap;
/**
* 注释:序列化帮助类
*/
public class SerializableUtil {
/**
*
* 注释:系列化工具
*
* @param object
* void
*/
public void serialize(Object object) {
}
/**
*
* 注释:反序列化工具
*
* @param msgMapBin
* @return
* @throws IOException
* @throws ClassNotFoundException
* HashMap
*/
public static HashMap unSerialize(byte[] msgMapBin) throws IOException,
ClassNotFoundException {
ObjectInputStream input = new ObjectInputStream(
new ByteArrayInputStream(msgMapBin));
HashMap result = (HashMap) input.readObject();
return result;
}
public static String unSerializeToString(byte[] msgMapBin) throws IOException,
ClassNotFoundException {
ObjectInputStream input = new ObjectInputStream(
new ByteArrayInputStream(msgMapBin));
String result = (String) input.readObject();
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy