Java Object Deserialize deserialize(byte[] serializedData, int startPos, int length)

Here you can find the source of deserialize(byte[] serializedData, int startPos, int length)

Description

Deserialize object from given byte array, starting at startPos and using length bytes.

License

Apache License

Parameter

Parameter Description
serializedData a parameter
startPos a parameter
length a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static Object deserialize(byte[] serializedData, int startPos, int length) throws IOException 

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 {
    /**/*from   w  w  w  .  j  a  v a2s  .c  o m*/
     * Deserialize object from given byte array, starting at startPos and using length bytes.
     *
     * @param serializedData
     * @param startPos
     * @param length
     * @return
     * @throws IOException
     */
    public static Object deserialize(byte[] serializedData, int startPos, int length) throws IOException {
        try (ObjectInputStream ois = new ObjectInputStream(
                new ByteArrayInputStream(serializedData, startPos, length))) {
            return ois.readObject();
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException("Unmarshalling exception", e);
        }
    }
}

Related

  1. deserialize(byte[] objectData)
  2. deserialize(byte[] serial)
  3. deserialize(byte[] serial)
  4. deserialize(byte[] serialized)
  5. deserialize(byte[] serializedData)
  6. deserialize(byte[] serializedObject)
  7. deserialize(byte[] sf)
  8. deserialize(final byte[] data)
  9. deserialize(final byte[] data)