public class ZipPackageInput extends java.lang.Object implements PackageInput
Reads entries from a zip file. Entries are stored in ZIP file in the same order they were entered with ZipPackageOutput. Searching entries is relatively smart, gotoEntry will scan the file from the current position for the requested entry, unless the entry has been seen already and it is known to be before the current file position. However it is always best to read entries in the order they appear in the file if possible. This avoids opening the file several times which in the case of a remote file means transferring the file several times over network.
| Modifier and Type | Field and Description |
|---|---|
private int |
currentEntry |
private java.util.List<java.lang.String> |
entries |
private java.util.List<java.lang.String> |
passedEntries |
private java.net.URL |
url |
private java.util.zip.ZipInputStream |
zis |
| Constructor and Description |
|---|
ZipPackageInput(java.io.File file)
Creates a new instance of ZipPackageInput
|
ZipPackageInput(java.lang.String file) |
ZipPackageInput(java.net.URL url) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the file.
|
java.util.Collection<java.lang.String> |
getEntries()
Gets the names of all entries in the file.
|
java.io.InputStream |
getInputStream()
Gets the input stream for current entry.
|
java.lang.String |
getSeparator()
Returns file separator used by the PackageInput.
|
boolean |
gotoEntry(java.lang.String name)
Moves to the entry with the specified name.
|
boolean |
gotoEntry(java.lang.String path,
java.lang.String name)
Moves to the entry that has the given path and name.
|
java.lang.String |
gotoNextEntry()
Goes to next entry in the file.
|
java.lang.String |
joinPath(java.lang.String path,
java.lang.String name)
Joins path and name, and returns joined resource name.
|
private void |
openStream() |
private java.net.URL url
private java.util.zip.ZipInputStream zis
private java.util.List<java.lang.String> entries
private java.util.List<java.lang.String> passedEntries
private int currentEntry
public ZipPackageInput(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic ZipPackageInput(java.lang.String file)
throws java.io.IOException
java.io.IOExceptionpublic ZipPackageInput(java.net.URL url)
throws java.io.IOException
java.io.IOExceptionprivate void openStream()
throws java.io.IOException
java.io.IOExceptionpublic boolean gotoEntry(java.lang.String name)
throws java.io.IOException
gotoEntry in interface PackageInputjava.io.IOExceptionpublic boolean gotoEntry(java.lang.String path,
java.lang.String name)
throws java.io.IOException
PackageInputgotoEntry in interface PackageInputjava.io.IOExceptionpublic java.lang.String gotoNextEntry()
throws java.io.IOException
gotoNextEntry in interface PackageInputjava.io.IOExceptionpublic java.io.InputStream getInputStream()
throws java.io.IOException
getInputStream in interface PackageInputjava.io.IOExceptionpublic java.util.Collection<java.lang.String> getEntries()
throws java.io.IOException
getEntries in interface PackageInputjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface PackageInputjava.io.IOExceptionpublic java.lang.String getSeparator()
PackageInputgetSeparator in interface PackageInputpublic java.lang.String joinPath(java.lang.String path,
java.lang.String name)
PackageInputjoinPath in interface PackageInputCopyright 2004-2015 Wandora Team