Package uk.ac.manchester.spinnaker.alloc
Class IOUtils
java.lang.Object
uk.ac.manchester.spinnaker.alloc.IOUtils
public abstract class IOUtils extends Object
Utility wrappers for I/O.
- Author:
- Donal Fellows
-
Method Summary
Modifier and Type Method Description static <T> T
deserialize(byte[] bytes, Class<T> cls)
Convert a serialized object into its normal form.static byte[]
serialize(Object obj)
Convert a serializable object into its serialized form.
-
Method Details
-
serialize
Convert a serializable object into its serialized form.- Parameters:
obj
- The object to serialize.- Returns:
- The serialized form.
- Throws:
IOException
- If the object isn't serializable.
-
deserialize
public static <T> T deserialize(byte[] bytes, Class<T> cls) throws ClassNotFoundException, IOExceptionConvert a serialized object into its normal form. Only call on data that is trusted!- Type Parameters:
T
- The type of the response.- Parameters:
bytes
- The serialized data.cls
- The class that the object is expected to conform to.- Returns:
- The deserialized object.
- Throws:
IOException
- If the object isn't deserializable.ClassNotFoundException
- If the data doesn't represent a known class.ClassCastException
- If the data is not an object of the expected class.
-