java.lang.Object
java.util.zip.Deflater
- See Also:
- Top Examples, Source Code,
Inflater
public static final int BEST_COMPRESSION
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int BEST_SPEED
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DEFAULT_COMPRESSION
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DEFAULT_STRATEGY
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int deflate(byte[] b)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[876]Compress a file to a bytearray
By Cipson J { dot } C { dot } on 2004/12/08 05:29:04 Rate
FileInputStream fin = new FileInputStream ( "20.doc" ) ;
while ( ( readByte = ( byte ) fin.read ( ) ) != -1 ) {
//System.out.println ( readByte ) ;
in [ i++ ] = readByte;
}
fin.close ( ) ;
// compressing the bytes
byte [ ] outputBuff = new byte [ 30000 ] ;
Deflater userDeflater = new Deflater ( ) ;
userDeflater.setLevel ( Deflater.BEST_COMPRESSION ) ;
userDeflater.setInput ( in ) ;
userDeflater.finish ( ) ;
//int datalen = userDeflater.deflate ( output ) ;
int datalen = 0;
while ( !userDeflater.finished ( ) ) {
datalen = userDeflater.deflate ( outputBuff ) ;
}
public int deflate(byte[] b,
int off,
int len)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DEFLATED
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Deflater()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1251]Create the compressor with highest level of compression
By Armic on 2005/01/13 06:52:34 Rate
Deflater compressor = new Deflater ( ) ;
compressor.setLevel ( Deflater.BEST_COMPRESSION ) ;
// Give the compressor the data to compress
compressor.setInput ( input ) ;
compressor.finish ( ) ;
// Create a byte array to hold the compressed data.
// There is no guarantee that the compressed data will be smaller than
// the uncompressed data.
ByteArrayOutputStream bos = new ByteArrayOutputStream ( input.length ) ;
// Compress the data
byte [ ] buf = new byte [ 1024 ] ;
while ( !compressor.finished ( ) ) {
int count = compressor.deflate ( buf ) ;
bos.write ( buf, 0, count ) ;
} // end while
try {
bos.close ( ) ;
} catch ( IOException e ) { }
// Get the compressed data
byte [ ] compressedData = bos.toByteArray ( ) ;
try {
FileOutputStream out = new FileOutputStream ( nameOfFile ) ;
out.write ( compressedData ) ;
out.flush ( ) ;
out.close ( ) ;
} catch ( Exception e ) { }
public Deflater(int level)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Deflater(int level,
boolean nowrap)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void end()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int FILTERED
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void finalize()
- See Also:
- Object
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void finish()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean finished()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getAdler()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public long getBytesRead()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public long getBytesWritten()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getTotalIn()
- See Also:
getBytesRead()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getTotalOut()
- See Also:
getBytesWritten()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int HUFFMAN_ONLY
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean needsInput()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int NO_COMPRESSION
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void reset()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setDictionary(byte[] b)
- See Also:
Inflater.getAdler()
, Inflater.inflate(byte[], int, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setDictionary(byte[] b,
int off,
int len)
- See Also:
Inflater.getAdler()
, Inflater.inflate(byte[], int, int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setInput(byte[] b)
- See Also:
needsInput()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setInput(byte[] b,
int off,
int len)
- See Also:
needsInput()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setLevel(int level)
- See Also:
- IllegalArgumentException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setStrategy(int strategy)
- See Also:
- IllegalArgumentException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples