Java Object Deserialize deserializeFromByte(byte[] value)

Here you can find the source of deserializeFromByte(byte[] value)

Description

deserialize From Byte

License

Apache License

Declaration

@SuppressWarnings("unchecked")
public static <V> V deserializeFromByte(byte[] value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

public class Main {

    @SuppressWarnings("unchecked")
    public static <V> V deserializeFromByte(byte[] value) {
        if (null == value || value.length <= 0) {
            return null;
        }/*from  ww  w  . ja  v  a 2 s .c om*/
        V reValue = null;
        ByteArrayInputStream bm = null;
        ObjectInputStream om = null;
        try {
            bm = new ByteArrayInputStream(value);
            om = new ObjectInputStream(bm);
            reValue = (V) om.readObject();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (null != om) {
                try {
                    om.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != bm) {
                try {
                    bm.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return reValue;
    }
}

Related

  1. deserialize(byte[] sf)
  2. deserialize(final byte[] data)
  3. deserialize(final byte[] data)
  4. deserialize(final byte[] inBytes)
  5. deserialize(final byte[] serialized)
  6. deserializeFromByteArray(byte[] bytes)
  7. deserializeFromByteArray(byte[] encodedValue, String description)
  8. deserializeFromByteArray(byte[] in)
  9. deserializeFromBytes(byte[] bytes, Class clazz)