public static byte[] serializeToByteArray(Serializable value){
  try {
    ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    try (ObjectOutputStream oos=new ObjectOutputStream(new SnappyOutputStream(buffer))){
      oos.writeObject(value);
    }
     return buffer.toByteArray();
  }
 catch (  IOException exn) {
    throw new IllegalArgumentException("unable to serialize " + value,exn);
  }
}

public static byte [ ] serializeToByteArray ( Serializable value ) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; try ( ObjectOutputStream oos = new ObjectOutputStream ( new SnappyOutputStream ( buffer ) ) ) { oos . writeObject ( value ) ; } return buffer . toByteArray ( ) ; } catch ( IOException exn ) { throw new IllegalArgumentException ( "unable to serialize " + value , exn ) ; } }
serializes the argument into an array of bytes , and returns it .
