SerializationUtils.java 1.01 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7 8 9 10 11
package cn.timer.api.utils;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.List;
/**
 * 反序列化
 * @author Administrator
 */
public class SerializationUtils {

12
	@SuppressWarnings("unchecked")
yuquan.zhu committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	public static List<Object> toSerialization(byte[] object) {
		try {
			ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(object);
			ObjectInputStream in;
			in = new ObjectInputStream(byteArrayInputStream);
			List<Object> objectlist = (List<Object>) in.readObject();
			in.close();
			return objectlist;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}
	
	public static Object toSerializationObject(byte[] object) {
		try {
			ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(object);
			ObjectInputStream in;
			in = new ObjectInputStream(byteArrayInputStream);
			Object objectlist = (Object) in.readObject();
			in.close();
			return objectlist;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}

}