public class ZipFileEntryInputStream extends InputStream
构造器和说明 |
---|
ZipFileEntryInputStream(File file, String entryName)
创建一个新的输入流,用于从 zip 文件中的一个条目读取解压缩数据。
|
ZipFileEntryInputStream(String filePath, String entryName)
创建一个新的输入流,用于从 zip 文件中的一个条目读取解压缩数据。
|
ZipFileEntryInputStream(ZipFile zipFile, String entryName)
创建一个新的输入流,用于从 zip 文件中的一个条目读取解压缩数据。
|
修饰符和类型 | 方法和说明 |
---|---|
int |
available(可用)()
获取 zip 文件条目的解压缩字节数。
|
void |
close(关闭)()
关闭到 zip 文件的输入流。
|
void |
mark(int readlimit)
在此输入流中设置标记位置。
|
boolean |
markSupported(支持标记)()
确定此输入流是否支持 mark() 和 reset() 方法。
|
int |
read(读取)()
从此流读取单个字节。
|
int |
read(byte[] buffer)
从源读取尽可能多的字节以填充给定数组。
|
int |
read(byte[] buffer, int offset, int length)
最多从流中读取“length”指定的字节数到给定缓冲区。
|
void |
reset(重置)()
将此流重置为上次标记的位置。
|
long |
skip(long byteCount)
跳过流中的给定字节数。
|
static ZipFileEntryInputStream |
tryOpen(File file, String entryName)
安全地打开到给定 zip 文件条目的输入流,不会引发异常。
|
static ZipFileEntryInputStream |
tryOpen(String filePath, String entryName)
安全地打开到给定 zip 文件条目的输入流,不会引发异常。
|
static ZipFileEntryInputStream |
tryOpen(ZipFile file, String entryName)
安全地打开到给定 zip 文件条目的输入流,不会引发异常。
|
public ZipFileEntryInputStream(String filePath, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
filePath
- 要访问的 zip 文件的路径和文件名。不能为空或空字符串。entryName
- zip 文件中条目的唯一名称。不能为空或空字符串。NullPointerException(空指针异常)
IllegalArgumentException(非法参数异常)
IllegalStateException (非法状态异常)
IOException(输入输出异常)
FileNotFoundException(文件未找到异常)
ZipException(Zip异常)
public ZipFileEntryInputStream(File file, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
file
- 要访问的 zip 文件。不能为空。entryName
- zip 文件中条目的唯一名称。不能为空或空字符串。NullPointerException(空指针异常)
IllegalArgumentException(非法参数异常)
IllegalStateException (非法状态异常)
IOException(输入输出异常)
FileNotFoundException(文件未找到异常)
ZipException(Zip异常)
public ZipFileEntryInputStream(ZipFile zipFile, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
file
- 要访问的 zip 文件。不能为空。entryName
- zip 文件中条目的唯一名称。不能为空或空字符串。NullPointerException(空指针异常)
IllegalArgumentException(非法参数异常)
IllegalStateException (非法状态异常)
IOException(输入输出异常)
FileNotFoundException(文件未找到异常)
ZipException(Zip异常)
public void close() throws IOException
Closeable
中的 close
AutoCloseable
中的 close
InputStream
中的 close
IOException(输入输出异常)
public int available() throws IOException
InputStream
中的 available
IOException(输入输出异常)
public void mark(int readlimit)
InputStream
中的 mark
readlimit
- 在标记失效之前可以从此流读取的字节数。public boolean markSupported()
InputStream
中的 markSupported
public void reset() throws IOException
InputStream
中的 reset
IOException(输入输出异常)
public int read() throws IOException
阻塞,直到读取了一个字节、到达源流的末尾或抛出异常为止。
InputStream
中的 read
如果已到达流的末尾,则返回 -1。
IOException(输入输出异常)
public int read(byte[] buffer) throws IOException, IndexOutOfBoundsException
InputStream
中的 read
buffer
- 将存储读取字节的字节数组。IOException(输入输出异常)
IndexOutOfBoundsException(索引越界异常)
public int read(byte[] buffer, int offset, int length) throws IOException, IndexOutOfBoundsException
InputStream
中的 read
buffer
- 将存储读取字节的字节数组。offset
- “buffer”数组中开始存储读取字节的位置的从零开始的索引。length
- 要读取的最大字节数。IOException(输入输出异常)
IndexOutOfBoundsException(索引越界异常)
public long skip(long byteCount) throws IOException
InputStream
中的 skip
byteCount
- 要跳过的字节数。如果小于或等于零,则不执行任何操作。IOException(输入输出异常)
public static ZipFileEntryInputStream tryOpen(String filePath, String entryName)
filePath
- 要访问的 zip 文件的路径和文件名。entryName
- zip 文件中条目的唯一名称。如果找不到给定的 zip 文件或其 zip 条目,则返回 null。
public static ZipFileEntryInputStream tryOpen(File file, String entryName)
file
- 要访问的 zip 文件。entryName
- zip 文件中条目的唯一名称。如果找不到给定的 zip 文件或其 zip 条目,则返回 null。
public static ZipFileEntryInputStream tryOpen(ZipFile file, String entryName)
file
- 要访问的 zip 文件。entryName
- zip 文件中条目的唯一名称。如果找不到给定的 zip 文件或其 zip 条目,则返回 null。