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
压缩方法压缩(放气)条目。
|
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
对未压缩的压缩方法(存储)的条目。
|
buf, def
out
Constructor and Description |
---|
ZipOutputStream(OutputStream out)
创建一个新的压缩输出流。
|
ZipOutputStream(OutputStream out, Charset charset)
创建一个新的压缩输出流。
|
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭压缩输出流,以及被过滤的流。
|
void |
closeEntry()
关闭当前的压缩条目并将流写入下一个条目。
|
void |
finish()
完成写的压缩输出流的内容,而不关闭底层流。
|
void |
putNextEntry(ZipEntry e)
开始编写一个新的压缩文件条目,并将流定位到输入数据的开始处。
|
void |
setComment(String comment)
设置文件注释。
|
void |
setLevel(int level)
设置后续deflated项压缩级别。
|
void |
setMethod(int method)
设置后续项的默认压缩方法。
|
void |
write(byte[] b, int off, int len)
将一个字节数组写入当前的压缩输入数据。
|
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)
charset
UTF-8编码采用项名称和评论。
out
-实际输出流
public ZipOutputStream(OutputStream out, Charset charset)
out
-实际输出流
charset
-
charset用来编码项名称和评论
public void setComment(String comment)
comment
-注释字符串
IllegalArgumentException
-如果指定压缩文件注释长度大于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
-拉链入口要写
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
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.