public interface Jar extends AutoCloseable
JarFile
and
JarInputStream
) have significantly different performance
characteristics depending on the form of the URL used to access the JAR.
For file based JAR URL
s, JarFile
is faster but for non-file
based URL
s, JarFile
creates a copy of the JAR in the
temporary directory so JarInputStream
is faster.Modifier and Type | Method and Description |
---|---|
void |
close()
Close any resources associated with this JAR.
|
boolean |
entryExists(String name)
Determines if a specific entry exists within the JAR.
|
InputStream |
getEntryInputStream()
Obtains the input stream for the current entry.
|
String |
getEntryName()
Obtains the name of the current entry.
|
InputStream |
getInputStream(String name)
Obtain an
InputStream for a given entry in a JAR. |
URL |
getJarFileURL()
Obtain the URL for accessing the JAR file.
|
long |
getLastModified(String name)
Obtain the last modified time for the given resource in the JAR.
|
String |
getURL(String entry)
Obtain, in String form, the URL for an entry in this JAR.
|
void |
nextEntry()
Moves the internal pointer to the next entry in the JAR.
|
void |
reset()
Resets the internal pointer used to track JAR entries to the beginning of
the JAR.
|
URL getJarFileURL()
boolean entryExists(String name) throws IOException
name
- Entry to look fortrue
if the specified entry exists else
false
IOException
InputStream getInputStream(String name) throws IOException
InputStream
for a given entry in a JAR. The caller is
responsible for closing the stream.name
- Entry to obtain an InputStream
forInputStream
for the specified entry or null if
the entry does not existIOException
long getLastModified(String name) throws IOException
name
- Entry to obtain the modification time forSystem.currentTimeMillis()
that the resource was last
modified. Returns -1 if the entry does not existIOException
void close()
close
in interface AutoCloseable
void nextEntry()
String getEntryName()
InputStream getEntryInputStream() throws IOException
IOException
- If the stream cannot be obtainedString getURL(String entry)
JarFactory
to ensure resources are accessed correctly.entry
- The entry to generate the URL forvoid reset() throws IOException
IOException
- If the pointer cannot be resetCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.