public GZIPArchive . WriteEntry getEntry ( final String name , final String comment , final Date creationDate ) { crc . reset ( ) ; deflater . reset ( ) ; deflaterStream . reset ( ) ; final GZIPArchive . WriteEntry entry = new GZIPArchive . WriteEntry ( ) ; entry . setName ( name ) ; entry . setComment ( comment ) ; entry . deflater = new FilterOutputStream ( new DeflaterOutputStream ( deflaterStream , deflater ) ) { private final byte [ ] oneCharBuffer = new byte [ 1 ] ; private long length = 0 ; @ Override public void write ( int b ) throws IOException { // This avoids byte-array creation in DeflaterOutputStream.write() oneCharBuffer [ 0 ] = ( byte ) b ; this . out . write ( oneCharBuffer ) ; crc . update ( oneCharBuffer ) ; this . length ++ ; } @ Override public void write ( byte [ ] b , int off , int len ) throws IOException { this . out . write ( b , off , len ) ; crc . update ( b , off , len ) ; this . length += len ; } @ Override public void close ( ) throws IOException { this . out . flush ( ) ; ( ( DeflaterOutputStream ) this . out ) . finish ( ) ; entry . compressedSkipLength = GZIPArchive . FIX_LEN + ( entry . name . length + 1 ) + ( entry . comment . length + 1 ) + deflaterStream . length ; entry . uncompressedSkipLength = ( int ) ( this . length & 0xFFFFFFFF ) ; entry . mtime = ( int ) ( creationDate . getTime ( ) / 1000 ) ; entry . crc32 = ( int ) ( crc . getValue ( ) & 0xFFFFFFFF ) ; writeEntry ( entry ) ; } } ; return entry ; }
Returns an object that can be used to write an entry in the GZIP archive .