All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.founder.core.utils.SerializableUtil Maven / Gradle / Ivy

There is a newer version: 3.2.3.2
Show newest version
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