public void compress(){
  IoBuffer tmp=IoBuffer.allocate(0);
  tmp.setAutoExpand(true);
  DeflaterOutputStream deflater=new DeflaterOutputStream(tmp.asOutputStream(),new Deflater(Deflater.BEST_COMPRESSION));
  byte[] tmpData=new byte[data.limit()];
  data.position(0);
  data.get(tmpData);
  try {
    deflater.write(tmpData);
    deflater.finish();
  }
 catch (  IOException e) {
    tmp.free();
    throw new RuntimeException("could not compress data",e);
  }
 finally {
    if (deflater != null) {
      try {
        deflater.close();
      }
 catch (      IOException e1) {
      }
    }
  }
  data.free();
  data=tmp;
  data.flip();
  prepareIO();
}

public void compress ( ) { IoBuffer tmp = IoBuffer . allocate ( 0 ) ; tmp . setAutoExpand ( true ) ; DeflaterOutputStream deflater = new DeflaterOutputStream ( tmp . asOutputStream ( ) , new Deflater ( Deflater . BEST_COMPRESSION ) ) ; byte [ ] tmpData = new byte [ data . limit ( ) ] ; data . position ( 0 ) ; data . get ( tmpData ) ; try { deflater . write ( tmpData ) ; deflater . finish ( ) ; } catch ( IOException e ) { tmp . free ( ) ; throw new RuntimeException ( "could not compress data" , e ) ; } finally { if ( deflater != null ) { try { deflater . close ( ) ; } catch ( IOException e1 ) { } } } data . free ( ) ; data = tmp ; data . flip ( ) ; prepareIO ( ) ; }
compress contents using zlib .
