Top Description Methods
org.apache.tomcat

public Interface Jar

extends AutoCloseable
Known Direct Implementers
org.apache.tomcat.util.scan.AbstractInputStreamJar, org.apache.tomcat.util.scan.JarFileUrlJar, org.apache.tomcat.util.scan.ReferenceCountedJar
Imports
java.io.IOException, .InputStream, java.net.URL, java.util.jar.Manifest

Provides an abstraction for use by the various classes that need to scan JARs. The classes provided by the JRE for accessing JARs (java.util.jar.JarFile and java.util.jar.JarInputStream) have significantly different performance characteristics depending on the form of the URL used to access the JAR. For file based JAR java.net.URLs, java.util.jar.JarFile is faster but for non-file based java.net.URLs, java.util.jar.JarFile creates a copy of the JAR in the temporary directory so java.util.jar.JarInputStream is faster.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.lang.AutoCloseable.close.

Close any resources associated with this JAR.

public boolean

Returns:

true if the entry is present in the JAR, otherwise false
exists
(String
Entry to look for
name
)

Determine if the given resource in present in the JAR.

public InputStream

Returns:

The input stream
getEntryInputStream
()

Obtains the input stream for the current entry.

public String

Returns:

The entry name
getEntryName
()

Obtains the name of the current entry.

public InputStream

Returns:

An InputStream for the specified entry or null if the entry does not exist
getInputStream
(String
Entry to obtain an InputStream for
name
)

Obtain an InputStream for a given entry in a JAR.

public URL

Returns:

The URL for accessing the JAR file.
getJarFileURL
()

public long

Returns:

The time (in the same format as System#currentTimeMillis() that the resource was last modified. Returns -1 if the entry does not exist
getLastModified
(String
Entry to obtain the modification time for
name
)

Obtain the last modified time for the given resource in the JAR.

public Manifest

Returns:

The manifest for this JAR file.
getManifest
()

Obtain the manifest for the JAR file.

public String

Returns:

a URL for the specified entry in the JAR
getURL
(String
The entry to generate the URL for
entry
)

Obtain, in String form, the URL for an entry in this JAR.

public void
nextEntry()

Moves the internal pointer to the next entry in the JAR.

public void
reset()

Resets the internal pointer used to track JAR entries to the beginning of the JAR.

Method Detail

closeback to summary
public void close()

Redeclares java.lang.AutoCloseable.close.

Close any resources associated with this JAR.

Annotations
@Override
existsback to summary
public boolean exists(String name) throws IOException

Determine if the given resource in present in the JAR.

Parameters
name:String

Entry to look for

Returns:boolean

true if the entry is present in the JAR, otherwise false

Exceptions
IOException:
if an I/O error occurs while processing the JAR file
getEntryInputStreamback to summary
public InputStream getEntryInputStream() throws IOException

Obtains the input stream for the current entry.

Returns:InputStream

The input stream

Exceptions
IOException:
If the stream cannot be obtained
getEntryNameback to summary
public String getEntryName()

Obtains the name of the current entry.

Returns:String

The entry name

getInputStreamback to summary
public InputStream getInputStream(String name) throws IOException

Obtain an InputStream for a given entry in a JAR. The caller is responsible for closing the stream.

Parameters
name:String

Entry to obtain an InputStream for

Returns:InputStream

An InputStream for the specified entry or null if the entry does not exist

Exceptions
IOException:
if an I/O error occurs while processing the JAR file
getJarFileURLback to summary
public URL getJarFileURL()
Returns:URL

The URL for accessing the JAR file.

getLastModifiedback to summary
public long getLastModified(String name) throws IOException

Obtain the last modified time for the given resource in the JAR.

Parameters
name:String

Entry to obtain the modification time for

Returns:long

The time (in the same format as System#currentTimeMillis() that the resource was last modified. Returns -1 if the entry does not exist

Exceptions
IOException:
if an I/O error occurs while processing the JAR file
getManifestback to summary
public Manifest getManifest() throws IOException

Obtain the manifest for the JAR file.

Returns:Manifest

The manifest for this JAR file.

Exceptions
IOException:
If an I/O error occurs trying to obtain the manifest
getURLback to summary
public String getURL(String entry)

Obtain, in String form, the URL for an entry in this JAR. Note that for JARs nested in WAR files, the Tomcat specific war:file:... form will not be used, rather the jar:jar:file:... form (that the JRE does not understand will be used). Note that this means that any code using these URLs will need to understand the jar:jar:file:... form and use the org.apache.tomcat.util.scan.JarFactory to ensure resources are accessed correctly.

Parameters
entry:String

The entry to generate the URL for

Returns:String

a URL for the specified entry in the JAR

nextEntryback to summary
public void nextEntry()

Moves the internal pointer to the next entry in the JAR.

resetback to summary
public void reset() throws IOException

Resets the internal pointer used to track JAR entries to the beginning of the JAR.

Exceptions
IOException:
If the pointer cannot be reset