📜  java.util.zip-Deflater类

📅  最后修改于: 2020-11-14 10:51:57             🧑  作者: Mango


介绍

java.util.zip.Deflater类使用流行的ZLIB压缩库为通用压缩提供支持。 ZLIB压缩库最初是作为PNG图形标准的一部分开发的,不受专利保护。在java.util.zip软件包说明中的规范中对其进行了全面描述。

类声明

以下是java.util.zip.Deflater类的声明-

public class Deflater
   extends Object

领域

以下是java.util.zip.Deflater类的字段-

  • static int BEST_COMPRESSION-最佳压缩级别。

  • static int BEST_SPEED-压缩级别,用于最快的压缩。

  • static int DEFAULT_COMPRESSION-默认压缩级别。

  • static int DEFAULT_STRATEGY-默认压缩策略。

  • static int DEFLATED -deflate算法的压缩方法(当前唯一支持的一种)。

  • static int FILTERED-压缩策略最适用于主要由较小值组成且具有一定随机分布的数据。

  • static int FULL_FLUSH-压缩刷新模式,用于刷新所有待处理的输出并重置泄气阀

  • static int HUFFMAN_ONLY-仅适用于霍夫曼编码的压缩策略。

  • static int NO_COMPRESSION-无压缩的压缩级别。

  • static int NO_FLUSH-压缩刷新模式用于获得最佳压缩结果。

  • static int SYNC_FLUSH-压缩刷新模式,用于刷新所有挂起的输出;可能会降低某些压缩算法的压缩率。

建设者

Sr.No. Constructor & Description
1

Deflater()

Creates a new compressor with the default compression level.

2

Deflater(int level)

Creates a new compressor using the specified compression level.

3

Deflater(int level, boolean nowrap)

Creates a new compressor using the specified compression level.

类方法

Sr.No. Method & Description
1 int deflate(byte[] b)

Compresses the input data and fills specified buffer with compressed data.

2 int deflate(byte[] b, int off, int len)

Compresses the input data and fills specified buffer with compressed data.

3 int deflate(byte[] b, int off, int len, int flush)

Compresses the input data and fills the specified buffer with compressed data.

4 void end()

Closes the compressor and discards any unprocessed input.

5 void finish()

When called, indicates that compression should end with the current contents of the input buffer.

6 boolean finished()

Returns true if the end of the compressed data output stream has been reached.

7 int getAdler()

Returns the ADLER-32 value of the uncompressed data.

8 long getBytesRead()

Returns the total number of uncompressed bytes input so far.

9 long getBytesWritten()

Returns the total number of compressed bytes output so far.

10 int getTotalIn()

Returns the total number of uncompressed bytes input so far.

11 int getTotalOut()

Returns the total number of compressed bytes output so far.

12 boolean needsInput()

Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.

13 void reset()

Resets deflater so that a new set of input data can be processed.

14 void setDictionary(byte[] b)

Sets preset dictionary for compression.

15 void setDictionary(byte[] b, int off, int len)

Sets preset dictionary for compression.

16 void setInput(byte[] b)

Sets input data for compression.

17 void setInput(byte[] b, int off, int len)

Sets input data for compression.

18 void setLevel(int level)

Sets the current compression level to the specified value.

19 void setStrategy(int strategy)

Sets the compression strategy to the specified value.

方法继承

此类从以下类继承方法-

  • java.lang.Object

打印