/**
* 纯hessian序列化
* @param object
* @return
* @throws Exception
*/
public static byte[] serialize(Object object) throws Exception{
if(object==null){
throw new NullPointerException();
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
HessianSerializerOutput hessianOutput=new HessianSerializerOutput(os);
hessianOutput.writeObject(object);
return os.toByteArray();
}
/**
* 纯hessian反序列化
* @param bytes
* @return
* @throws Exception
*/
public static Object deserialize(byte[] bytes) throws Exception{
if(bytes==null){
throw new NullPointerException();
}
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
HessianSerializerInput hessianInput=new HessianSerializerInput(is);
Object object = hessianInput.readObject();
return object;
}
/**
* java序列化
* @param obj
* @return
* @throws Exception
*/
public static byte[] serialize(Object obj) throws Exception {
if (obj == null)
throw new NullPointerException();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(os);
out.writeObject(obj);
return os.toByteArray();
}
/**
* java反序列化
* @param by
* @return
* @throws Exception
*/
public static Object deserialize(byte[] by) throws Exception {
if (by == null)
throw new NullPointerException();
ByteArrayInputStream is = new ByteArrayInputStream(by);
ObjectInputStream in = new ObjectInputStream(is);
return in.readObject();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有