public final class ObjectSerializer extends Object
| Constructor and Description |
|---|
ObjectSerializer() |
| Modifier and Type | Method and Description |
|---|---|
<T extends Serializable> |
readObject(Class<T> expectedType,
byte[] byteStream)
Deserializes an object of the specified type from the provided byte stream.
|
byte[] |
writeObject(Serializable object)
Serializes the
Serializable object passed and returns it as a byte array. |
public final <T extends Serializable> T readObject(Class<T> expectedType, byte[] byteStream) throws ObjectDeserializationException
expectedType - The type that is expected to be retrieved from byteStream (must implement Serializable)byteStream - The byte stream to retrieve the object from (it must contain exactly one object, of the exact type passed to expectedType)ObjectTypeNotExpectedException - If the object found in the stream does not match the type expectedType or if a ClassNotFoundException or NoClassDefFoundError occursObjectDeserializationException - If an I/O exception occurs while deserializing the object from the streampublic final byte[] writeObject(Serializable object) throws ObjectSerializationException
Serializable object passed and returns it as a byte array.object - The object to serializeObjectSerializationException - if an I/O exception occurs while serializing the object.Copyright © 2010-2013 NWTS Java Code. All Rights Reserved. Licensed Under the Apache License version 2.0.