Java Utililty Methods Byte Array to Object

List of utility methods to do Byte Array to Object

Description

The list of methods to do Byte Array to Object are organized into topic(s).

Method

Serializabledeserialize(byte[] array)
deserialize
if (array == null) {
    return null;
try {
    return deserializeRaw(array);
} catch (IOException e) {
    e.printStackTrace();
    return null;
...
Objectdeserialize(byte[] b)
deserialize
Object obj = null;
ObjectInputStream oin = null;
try {
    ByteArrayInputStream bin = new ByteArrayInputStream(b);
    oin = new ObjectInputStream(bin);
    obj = oin.readObject();
    return obj;
} finally {
...
Objectdeserialize(byte[] blob)
Deserialise the specified blob into an Object and return it to the client.
if (blob == null) {
    throw new IllegalArgumentException("null blob to deserialize");
ByteArrayInputStream bstream = new ByteArrayInputStream(blob);
ObjectInputStream istream = new ObjectInputStream(bstream);
return istream.readObject();
Serializabledeserialize(byte[] buf)
Returns the object deserialized from the given byte array.
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
ObjectInputStream ois = new ObjectInputStream(bais);
try {
    return (Serializable) ois.readObject();
} catch (ClassNotFoundException ex) {
    ex.printStackTrace();
    throw new IllegalStateException(ex.getMessage());
} finally {
...
Tdeserialize(byte[] buf)
deserialize
try {
    ByteArrayInputStream bis = null;
    try {
        bis = new ByteArrayInputStream(buf);
        ObjectInputStream oin = null;
        try {
            oin = new ObjectInputStream(bis);
            return (T) oin.readObject();
...
Object[]deserialize(byte[] buffer, int count)
This method takes the given buffer and extracts count number of objects from it.
try {
    Object[] objects = new Object[count];
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    ObjectInputStream ois = new ObjectInputStream(bais);
    for (int i = 0; i < count; i++)
        objects[i] = ois.readObject();
    ois.close();
    return objects;
...
Serializabledeserialize(byte[] byteArray)
deserialize
return deserialize(byteArray, Thread.currentThread().getContextClassLoader());
Tdeserialize(byte[] byteArray)
deserialize
ObjectInputStream oip = null;
try {
    oip = new ObjectInputStream(new ByteArrayInputStream(byteArray));
    @SuppressWarnings("unchecked")
    T result = (T) oip.readObject();
    return result;
} catch (IOException e) {
    throw new IllegalArgumentException(e);
...
Objectdeserialize(byte[] bytes)
deserialize
if (bytes == null) {
    return null;
try {
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
    return ois.readObject();
} catch (IOException ex) {
    throw new IllegalArgumentException("Failed to deserialize object", ex);
...
Objectdeserialize(byte[] bytes)
Deserializes an object.
if ((bytes == null) || (bytes.length == 0))
    return null;
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
try {
    ObjectInputStream stream = new ObjectInputStream(byteStream);
    try {
        return stream.readObject();
    } finally {
...