public class ZipOutputStream extends DeflaterOutputStream
Modifier and Type | Field and Description |
---|---|
static int |
CENATT |
static int |
CENATX |
static int |
CENCOM |
static int |
CENCRC |
static int |
CENDSK |
static int |
CENEXT |
static int |
CENFLG |
static int |
CENHDR |
static int |
CENHOW |
static int |
CENLEN |
static int |
CENNAM |
static int |
CENOFF |
static long |
CENSIG |
static int |
CENSIZ |
static int |
CENTIM |
static int |
CENVEM |
static int |
CENVER |
static int |
DEFLATED
压缩(DEFLATED)条目的压缩方法。
|
static int |
ENDCOM |
static int |
ENDHDR |
static int |
ENDOFF |
static long |
ENDSIG |
static int |
ENDSIZ |
static int |
ENDSUB |
static int |
ENDTOT |
static int |
EXTCRC |
static int |
EXTHDR |
static int |
EXTLEN |
static long |
EXTSIG |
static int |
EXTSIZ |
static int |
LOCCRC |
static int |
LOCEXT |
static int |
LOCFLG |
static int |
LOCHDR |
static int |
LOCHOW |
static int |
LOCLEN |
static int |
LOCNAM |
static long |
LOCSIG |
static int |
LOCSIZ |
static int |
LOCTIM |
static int |
LOCVER |
static int |
STORED
未压缩(STORED)条目的压缩方法。
|
buf, def
out
Constructor and Description |
---|
ZipOutputStream(OutputStream out)
创建一个新的ZIP输出流。
|
ZipOutputStream(OutputStream out, Charset charset)
创建一个新的ZIP输出流。
|
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭ZIP输出流以及正在过滤的流。
|
void |
closeEntry()
关闭当前的ZIP条目,并定位流以写入下一个条目。
|
void |
finish()
完成编写ZIP输出流的内容,而不关闭底层流。
|
void |
putNextEntry(ZipEntry e)
开始编写新的ZIP文件条目,并将流定位到条目数据的开头。
|
void |
setComment(String comment)
设置ZIP文件注释。
|
void |
setLevel(int level)
设置DEFLATED的后续条目的压缩级别。
|
void |
setMethod(int method)
设置后续条目的默认压缩方法。
|
void |
write(byte[] b, int off, int len)
将一个字节数组写入当前的ZIP条目数据。
|
deflate, flush, write
write
public static final int STORED
public static final int DEFLATED
public static final long LOCSIG
public static final long EXTSIG
public static final long CENSIG
public static final long ENDSIG
public static final int LOCHDR
public static final int EXTHDR
public static final int CENHDR
public static final int ENDHDR
public static final int LOCVER
public static final int LOCFLG
public static final int LOCHOW
public static final int LOCTIM
public static final int LOCCRC
public static final int LOCSIZ
public static final int LOCLEN
public static final int LOCNAM
public static final int LOCEXT
public static final int EXTCRC
public static final int EXTSIZ
public static final int EXTLEN
public static final int CENVEM
public static final int CENVER
public static final int CENFLG
public static final int CENHOW
public static final int CENTIM
public static final int CENCRC
public static final int CENSIZ
public static final int CENLEN
public static final int CENNAM
public static final int CENEXT
public static final int CENCOM
public static final int CENDSK
public static final int CENATT
public static final int CENATX
public static final int CENOFF
public static final int ENDSUB
public static final int ENDTOT
public static final int ENDSIZ
public static final int ENDOFF
public static final int ENDCOM
public ZipOutputStream(OutputStream out)
UTF-8 charset
用于对条目名称和注释进行编码。
out
- 实际的输出流
public ZipOutputStream(OutputStream out, Charset charset)
out
- 实际的输出流
charset
- 用于对条目名称和注释进行编码的charset
public void setComment(String comment)
comment
- 注释字符串
IllegalArgumentException
- 如果指定的ZIP文件注释的长度大于0xFFFF个字节
public void setMethod(int method)
method
- 默认的压缩方法
IllegalArgumentException
- 如果指定的压缩方法无效
public void setLevel(int level)
level
- 压缩级别(0-9)
IllegalArgumentException
- 如果压缩级别无效
public void putNextEntry(ZipEntry e) throws IOException
e
- 要写入的ZIP条目
ZipException
- 如果发生ZIP格式错误
IOException
- 如果发生I / O错误
public void closeEntry() throws IOException
ZipException
- 如果发生ZIP格式错误
IOException
- 如果发生I / O错误
public void write(byte[] b, int off, int len) throws IOException
write
在
DeflaterOutputStream
b
- 要写入的数据
off
- 数据中的起始偏移量
len
- 写入的字节数
ZipException
- 如果发生ZIP文件错误
IOException
- 如果发生I / O错误
FilterOutputStream.write(int)
public void finish() throws IOException
finish
在类别
DeflaterOutputStream
ZipException
- 如果发生ZIP文件错误
IOException
- 如果发生I / O异常
public void close() throws IOException
close
在界面
Closeable
close
在界面
AutoCloseable
close
在
DeflaterOutputStream
ZipException
- 如果发生ZIP文件错误
IOException
- 如果发生I / O错误
FilterOutputStream.flush()
,
FilterOutputStream.out