public static void writeGzipObjectToStream ( final Object o , OutputStream out ) { out = new BufferedOutputStream ( out ) ; try { out = new GZIPOutputStream ( out , true ) ; final ObjectOutputStream oos = new ObjectOutputStream ( out ) ; oos . writeObject ( o ) ; oos . flush ( ) ; } catch ( final IOException e ) { e . printStackTrace ( ) ; } }
Serialized gzipped java object to an ObjectOutputStream . The stream remains open .