java.lang.AutoCloseable
AbstractInputStreamJar
, JarFileUrlJar
, JarFileUrlNestedJar
, ReferenceCountedJar
, UrlJar
public interface Jar
extends java.lang.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 | Description |
---|---|---|
void |
close() |
Close any resources associated with this JAR.
|
boolean |
exists(java.lang.String name) |
Determine if the given resource in present in the JAR.
|
java.io.InputStream |
getEntryInputStream() |
Obtains the input stream for the current entry.
|
java.lang.String |
getEntryName() |
Obtains the name of the current entry.
|
java.io.InputStream |
getInputStream(java.lang.String name) |
Obtain an
InputStream for a given entry in a JAR. |
java.net.URL |
getJarFileURL() |
|
long |
getLastModified(java.lang.String name) |
Obtain the last modified time for the given resource in the JAR.
|
java.util.jar.Manifest |
getManifest() |
Obtain the manifest for the JAR file.
|
java.lang.String |
getURL(java.lang.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.
|
java.net.URL getJarFileURL()
java.io.InputStream getInputStream(java.lang.String name) throws java.io.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 existjava.io.IOException
- if an I/O error occurs while processing the JAR filelong getLastModified(java.lang.String name) throws java.io.IOException
name
- Entry to obtain the modification time forSystem.currentTimeMillis()
that the resource was last
modified. Returns -1 if the entry does not existjava.io.IOException
- if an I/O error occurs while processing the JAR fileboolean exists(java.lang.String name) throws java.io.IOException
name
- Entry to look fortrue
if the entry is present in the JAR, otherwise
false
java.io.IOException
- if an I/O error occurs while processing the JAR filevoid close()
close
in interface java.lang.AutoCloseable
void nextEntry()
java.lang.String getEntryName()
java.io.InputStream getEntryInputStream() throws java.io.IOException
java.io.IOException
- If the stream cannot be obtainedjava.lang.String getURL(java.lang.String entry)
JarFactory
to ensure resources are
accessed correctly.entry
- The entry to generate the URL forjava.util.jar.Manifest getManifest() throws java.io.IOException
java.io.IOException
- If an I/O error occurs trying to obtain the manifestvoid reset() throws java.io.IOException
java.io.IOException
- If the pointer cannot be resetCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.