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 Details

    • serialize

      public static byte[] serialize​(Object obj) throws IOException
      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, IOException
      Convert 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.