public static byte[] serialize(CAS cas) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); Serialization.serializeWithCompression(cas, out); out.close(); return bos.toByteArray(); }