public class ZipFileEntryInputStream extends InputStream
Constructor and Description |
---|
ZipFileEntryInputStream(File file,
String entryName)
Creates a new input stream for reading decompressed data from one entry within a zip file.
|
ZipFileEntryInputStream(String filePath,
String entryName)
Creates a new input stream for reading decompressed data from one entry within a zip file.
|
ZipFileEntryInputStream(ZipFile zipFile,
String entryName)
Creates a new input stream for reading decompressed data from one entry within a zip file.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Gets the number of decompressed bytes of the zip file's entry.
|
void |
close()
Closes the input stream to the zip file.
|
void |
mark(int readlimit)
Sets a mark position in this input stream.
|
boolean |
markSupported()
Determines if this input stream supports the mark() and reset() methods.
|
int |
read()
Reads a single byte from this stream.
|
int |
read(byte[] buffer)
Reads as many bytes from the source that will fill the given array.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads at most the number of bytes specified by "length" from the stream to the given buffer.
|
void |
reset()
Resets this stream to the last marked location.
|
long |
skip(long byteCount)
Skips the given number of bytes in the stream.
|
static ZipFileEntryInputStream |
tryOpen(File file,
String entryName)
Safely opens an input stream to the given zip file entry without exceptions.
|
static ZipFileEntryInputStream |
tryOpen(String filePath,
String entryName)
Safely opens an input stream to the given zip file entry without exceptions.
|
static ZipFileEntryInputStream |
tryOpen(ZipFile file,
String entryName)
Safely opens an input stream to the given zip file entry without exceptions.
|
public ZipFileEntryInputStream(String filePath, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
filePath
- The path and file name of the zip file to be accessed. Cannot be null or empty.entryName
- The unique name of the entry within the zip file. Cannot be null or empty.NullPointerException
IllegalArgumentException
IllegalStateException
IOException
FileNotFoundException
ZipException
public ZipFileEntryInputStream(File file, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
file
- The zip file to be accessed. Cannot be null.entryName
- The unique name of the entry within the zip file. Cannot be null or empty.NullPointerException
IllegalArgumentException
IllegalStateException
IOException
FileNotFoundException
ZipException
public ZipFileEntryInputStream(ZipFile zipFile, String entryName) throws NullPointerException, IllegalArgumentException, IllegalStateException, IOException, FileNotFoundException, ZipException
file
- The zip file to be accessed. Cannot be null.entryName
- The unique name of the entry within the zip file. Cannot be null or empty.NullPointerException
IllegalArgumentException
IllegalStateException
IOException
FileNotFoundException
ZipException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
readlimit
- The number of bytes that can be read from this stream before the mark is invalidated.public boolean markSupported()
markSupported
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public int read() throws IOException
Blocks until one byte has been read, the end of the source stream has been reached, or when an exception has been thrown.
read
in class InputStream
Returns -1 if the end of the stream has been reached.
IOException
public int read(byte[] buffer) throws IOException, IndexOutOfBoundsException
read
in class InputStream
buffer
- The byte array which will stored the read bytes.IOException
IndexOutOfBoundsException
public int read(byte[] buffer, int offset, int length) throws IOException, IndexOutOfBoundsException
read
in class InputStream
buffer
- The byte array which will stored the read bytes.offset
- Zero based index to the position in the "buffer" array to start storing read bytes.length
- The maximum number of bytes to read.IOException
IndexOutOfBoundsException
public long skip(long byteCount) throws IOException
skip
in class InputStream
byteCount
- The number of bytes to skip. Does nothing if less than or equal to zero.IOException
public static ZipFileEntryInputStream tryOpen(String filePath, String entryName)
filePath
- The path and file name of the zip file to be accessed.entryName
- The unique name of the entry within the zip file.Returns null if failed to find the given zip file or its zip entry.
public static ZipFileEntryInputStream tryOpen(File file, String entryName)
file
- The zip file to be accessed.entryName
- The unique name of the entry within the zip file.Returns null if failed to find the given zip file or its zip entry.
public static ZipFileEntryInputStream tryOpen(ZipFile file, String entryName)
file
- The zip file to be accessed.entryName
- The unique name of the entry within the zip file.Returns null if failed to find the given zip file or its zip entry.