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 protectedSerializationUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tdeserialize(byte[] bytes)Deserializes object from byte arraystatic <T> Tdeserialize(InputStream is)Deserializes object from InputStreamstatic <T> TfromByteArray(byte[] bytes)Deserializes object from byte arraystatic <T> TreadObject(File file)static <T> TreadObject(InputStream is)Reads an object from the given input streamstatic voidsaveObject(Object toSave, File saveTo)static voidserialize(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 voidwriteObject(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
-
-