Class ByteUtils

java.lang.Object
com.gigaspaces.internal.utils.ByteUtils

public class ByteUtils extends Object
Convenient methods for converting objects to and from bytes.
Since:
7.0
Author:
Moran Avigdor
  • Constructor Details

    • ByteUtils

      public ByteUtils()
  • Method Details

    • objectToBytes

      public static byte[] objectToBytes(Object obj) throws IOException
      Convert an object into byte array.
      Parameters:
      obj - an object that implements Serializable
      Returns:
      a byte array representing this object.
      Throws:
      IOException - if an I/O error occurs while writing stream header.
    • bytesToObject

      public static Object bytesToObject(byte[] bytes) throws IOException, ClassNotFoundException
      Convert a byte array into an object.
      Parameters:
      bytes - a byte array representing the object.
      Returns:
      an object.
      Throws:
      IOException - if an I/O error occurs while reading stream header.
      ClassNotFoundException - Class of a serialized object cannot be found