SerializationUtils.java 1.01 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5
package cn.timer.api.utils;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.List;
6

yuquan.zhu committed
7 8
/**
 * 反序列化
9
 * 
yuquan.zhu committed
10 11 12 13
 * @author Administrator
 */
public class SerializationUtils {

14
	@SuppressWarnings("unchecked")
yuquan.zhu committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28
	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;
		}

	}
29

yuquan.zhu committed
30 31 32 33 34 35 36 37 38 39 40 41
	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;
		}
42

yuquan.zhu committed
43 44 45
	}

}