Name
JarURLConnection
Synopsis
This
class is a specialized URLConnection that
represents a connection to a jar: URL. A
jar: URL is a compound URL that includes the URL
of a JAR archive and, optionally, a reference to a file or directory
within the JAR archive. The jar: URL syntax uses
the ! character
to separate the pathname of the JAR archive from the
filename within the JAR archive. Note that a jar:
URL contains a subprotocol that specifies the protocol that retrieves
the JAR file itself. For example:
jar:http://my.jar.com/my.jar!/ // The whole archive jar:file:/usr/java/lib/my.jar!/com/jar/ // A directory of the archive jar:ftp://ftp.jar.com/pub/my.jar!/com/jar/Jar.class // A file in the archive
To obtain a JarURLConnection, define a
URL object for a jar: URL, open
a connection to it with openConnection( ), and
cast the returned URLConnection object to a
JarURLConnection. The various methods defined by
JarURLConnection allow you to read the manifest
file of the JAR archive and look up attributes from that manifest for
the archive as a whole or for individual entries in the archive.
These methods make use of various classes from the
java.util.jar
package.
Figure 12-10. java.net.JarURLConnection
public abstract class JarURLConnection extends URLConnection { // Protected Constructors protected JarURLConnection(URL url) throws MalformedURLException; // Public Instance Methods public ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access