Package org.nd4j.common.util
Class SerializationUtils
- java.lang.Object
-
- org.nd4j.common.util.SerializationUtils
-
public class SerializationUtils extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SerializationUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
deserialize(byte[] bytes)
Deserializes object from byte arraystatic <T> T
deserialize(InputStream is)
Deserializes object from InputStreamstatic <T> T
fromByteArray(byte[] bytes)
Deserializes object from byte arraystatic <T> T
readObject(File file)
static <T> T
readObject(InputStream is)
Reads an object from the given input streamstatic void
saveObject(Object toSave, File saveTo)
static void
serialize(Serializable object, OutputStream os)
Writes the object to the output stream THIS DOES NOT FLUSH THE STREAMstatic byte[]
toByteArray(Serializable toSave)
Converts the given object to a byte arraystatic void
writeObject(Serializable toSave, OutputStream writeTo)
Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM
-
-
-
Method Detail
-
readObject
public static <T> T readObject(File file)
-
readObject
public static <T> T readObject(InputStream is)
Reads an object from the given input stream- Parameters:
is
- the input stream to read from- Returns:
- the read object
-
toByteArray
public static byte[] toByteArray(Serializable toSave)
Converts the given object to a byte array- Parameters:
toSave
- the object to save
-
fromByteArray
public static <T> T fromByteArray(byte[] bytes)
Deserializes object from byte array- Type Parameters:
T
-- Parameters:
bytes
-- Returns:
-
deserialize
public static <T> T deserialize(byte[] bytes)
Deserializes object from byte array- Type Parameters:
T
-- Parameters:
bytes
-- Returns:
-
deserialize
public static <T> T deserialize(InputStream is)
Deserializes object from InputStream- Type Parameters:
T
-- Parameters:
bytes
-- Returns:
-
writeObject
public static void writeObject(Serializable toSave, OutputStream writeTo)
Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM- Parameters:
toSave
- the object to savewriteTo
- the output stream to write to
-
serialize
public static void serialize(Serializable object, OutputStream os)
Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM- Parameters:
toSave
- the object to savewriteTo
- the output stream to write to
-
-