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.IOException
public ZipPackageInput(java.lang.String file) throws java.io.IOException
java.io.IOException
public ZipPackageInput(java.net.URL url) throws java.io.IOException
java.io.IOException
private void openStream() throws java.io.IOException
java.io.IOException
public boolean gotoEntry(java.lang.String name) throws java.io.IOException
gotoEntry
in interface PackageInput
java.io.IOException
public boolean gotoEntry(java.lang.String path, java.lang.String name) throws java.io.IOException
PackageInput
gotoEntry
in interface PackageInput
java.io.IOException
public java.lang.String gotoNextEntry() throws java.io.IOException
gotoNextEntry
in interface PackageInput
java.io.IOException
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in interface PackageInput
java.io.IOException
public java.util.Collection<java.lang.String> getEntries() throws java.io.IOException
getEntries
in interface PackageInput
java.io.IOException
public void close() throws java.io.IOException
close
in interface PackageInput
java.io.IOException
public java.lang.String getSeparator()
PackageInput
getSeparator
in interface PackageInput
public java.lang.String joinPath(java.lang.String path, java.lang.String name)
PackageInput
joinPath
in interface PackageInput
Copyright 2004-2015 Wandora Team