java.util.zip.Deflater類為使用流行的ZLIB壓縮庫的通用壓縮提供支持。 ZLIB壓縮庫最初是作為PNG圖形標(biāo)準(zhǔn)的一部分開發(fā)的,不受專利保護(hù)。 它在java.util.zip包描述的規(guī)范中有詳細(xì)描述。
以下是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 - 默認(rèn)壓縮級別。static int DEFAULT_STRATEGY - 默認(rèn)壓縮策略。static int DEFLATED - 壓縮算法的壓縮方法(目前唯一支持的壓縮方法)。static int FILTERED - 壓縮策略最適用于大部分?jǐn)?shù)值較小且數(shù)據(jù)分布隨機(jī)分布的數(shù)據(jù)。static int FULL_FLUSH - 壓縮刷新模式,用于清除所有待處理的輸出并重置拆卸器。static int HUFFMAN_ONLY - 僅用于霍夫曼編碼的壓縮策略。static int NO_COMPRESSION - 不壓縮的壓縮級別。static int NO_FLUSH - 用于實(shí)現(xiàn)最佳壓縮結(jié)果的壓縮刷新模式。static int SYNC_FLUSH - 用于清除所有未決輸出的壓縮刷新模式; 可能會降低某些壓縮算法的壓縮率。| 編號 | 構(gòu)造方法 | 描述 |
|---|---|---|
| 1 | Deflater() |
用默認(rèn)的壓縮級別創(chuàng)建一個新的壓縮器。 |
| 2 | Deflater(int level) |
使用指定的壓縮級別創(chuàng)建一個新的壓縮器。 |
| 3 | Deflater(int level, boolean nowrap) |
使用指定的壓縮級別創(chuàng)建一個新的壓縮器。 |
| 編號 | 方法 | 描述 |
|---|---|---|
| 1 | int deflate(byte[] b) | 壓縮輸入數(shù)據(jù)并用壓縮數(shù)據(jù)填充指定的緩沖區(qū)。 |
| 2 | int deflate(byte[] b, int off, int len) | 壓縮輸入數(shù)據(jù)并用壓縮數(shù)據(jù)填充指定的緩沖區(qū)。 |
| 3 | int deflate(byte[] b, int off, int len, int flush) | 壓縮輸入數(shù)據(jù)并用壓縮數(shù)據(jù)填充指定的緩沖區(qū)。 |
| 4 | void end() | 關(guān)閉壓縮器并丟棄任何未處理的輸入。 |
| 5 | void finish() | 當(dāng)被調(diào)用時,表示壓縮應(yīng)該以輸入緩沖區(qū)的當(dāng)前內(nèi)容結(jié)束。 |
| 6 | boolean finished() | 如果已達(dá)到壓縮數(shù)據(jù)輸出流的結(jié)尾,則返回true。 |
| 7 | int getAdler() | 返回未壓縮數(shù)據(jù)的ADLER-32值。 |
| 8 | long getBytesRead() | 返回到目前為止輸入的未壓縮字節(jié)的總數(shù)。 |
| 9 | long getBytesWritten() | 返回迄今為止輸出的壓縮字節(jié)總數(shù)。 |
| 10 | int getTotalIn() | 返回到目前為止輸入的未壓縮字節(jié)的總數(shù)。 |
| 11 | int getTotalOut() | 返回迄今為止輸出的壓縮字節(jié)總數(shù)。 |
| 12 | boolean needsInput() | 如果輸入數(shù)據(jù)緩沖區(qū)為空,并且應(yīng)該調(diào)用setInput()以提供更多輸入,則返回true。 |
| 13 | void reset() | 重置deflater,以便可以處理一組新的輸入數(shù)據(jù)。 |
| 14 | void setDictionary(byte[] b) | 設(shè)置預(yù)設(shè)字典進(jìn)行壓縮。 |
| 15 | void setDictionary(byte[] b, int off, int len) | 設(shè)置預(yù)設(shè)字典進(jìn)行壓縮。 |
| 16 | void setInput(byte[] b) | 設(shè)置壓縮輸入數(shù)據(jù)。 |
| 17 | void setInput(byte[] b, int off, int len) | 設(shè)置壓縮輸入數(shù)據(jù)。 |
| 18 | void setLevel(int level) | 將當(dāng)前壓縮級別設(shè)置為指定值。 |
| 19 | void setStrategy(int strategy) | 將壓縮策略設(shè)置為指定的值。 |
這個類繼承了以下類的方法 -
java.lang.Object