public class SerializationUtils extends java.lang.Object
Constructor and Description |
---|
SerializationUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends java.io.Serializable> |
cloneBySerialization(T t,
java.lang.ClassLoader classLoader)
Returns a copy of the given object obtained by serialization and
deserialization in memory.
|
static java.io.Serializable |
deserializeFromByteArray(byte[] bytes,
java.lang.ClassLoader classLoader)
Make use of StorageUtils#deserialize(byte[]) whenever possible.
|
static int |
extractInt(byte[] bytes,
int position)
Extracts an int value from the given array position (4 bytes in big
endian).
|
static void |
insertInt(int i,
byte[] bytes,
int position)
Inserts an int value to the given position in the byte array.
|
static byte[] |
serializeToByteArray(java.io.Serializable object)
Serializes an object to byte array
|
public SerializationUtils()
public static byte[] serializeToByteArray(java.io.Serializable object) throws java.io.IOException
java.io.IOException
public static java.io.Serializable deserializeFromByteArray(byte[] bytes, java.lang.ClassLoader classLoader) throws java.io.IOException, java.lang.ClassNotFoundException
null
if a
null
value is passed.classLoader
- the class loader used. If this is null, the default behavior
of ObjectInputStream
is used, i.e. if there is a
method on the current call stack whose class was loaded via a
custom class loader, this class loader is used. Otherwise the
default class loader is used. Also see the documentation of
ObjectInputStream
s resolveClass() method.java.io.IOException
java.lang.ClassNotFoundException
public static <T extends java.io.Serializable> T cloneBySerialization(T t, java.lang.ClassLoader classLoader)
classLoader
- the class loader used. If this is null, the default behavior
of ObjectInputStream
is used, i.e. if there is a
method on the current call stack whose class was loaded via a
custom class loader, this class loader is used. Otherwise the
default class loader is used. Also see the documentation of
ObjectInputStream
s resolveClass() method.public static void insertInt(int i, byte[] bytes, int position)
public static int extractInt(byte[] bytes, int position)
insertInt(int, byte[], int)
.