public abstract class JarURLConnection extends URLConnection
jar: URL using the JAR protocol. A JarURLConnection instance can refer to either a JAR
archive file or to an entry of such a file. jar: URLs are specified
as follows: jar:{archive-url}!/{entry} where "!/" is called a
separator. This separator is important to determine if an archive or an entry
of an archive is referred.
Examples:
jar:http://www.example.com/applets/archive.jar!/jar:http://www.example.com/applets/archive.jar!/test.classjar:http://www.example.com/applets/archive.jar!/applets/
This class has different behavior depending on the URLConnection.getUseCaches()
setting. When caching is enabled the underlying JarFile returned from
getJarFile() is cached and shared between connections. It must not be
closed by the caller. Disabling caching using URLConnection.setUseCaches(boolean)
will prevent sharing but in the absence of a
JarURLConnection.disconnect() method the only way to close the
underlying JarFile is to call getJarFile().close()
or getInputStream().close(). For uncached connections, closing the
JarFile can prevent various other URLConnection methods from
working.
| Modifier and Type | Field and Description |
|---|---|
protected URLConnection |
jarFileURLConnection
The location part of the represented URL.
|
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches| Modifier | Constructor and Description |
|---|---|
protected |
JarURLConnection(URL url)
Constructs an instance of
JarURLConnection that refers to the
specified URL. |
| Modifier and Type | Method and Description |
|---|---|
Attributes |
getAttributes()
Returns all attributes of the
JarEntry referenced by this JarURLConnection. |
Certificate[] |
getCertificates()
Returns all certificates of the
JarEntry referenced by this
JarURLConnection instance. |
String |
getEntryName()
Gets the name of the entry referenced by this
JarURLConnection. |
JarEntry |
getJarEntry()
Gets the
JarEntry object of the entry referenced by this JarURLConnection. |
abstract JarFile |
getJarFile()
Gets the
JarFile object referenced by this JarURLConnection. |
URL |
getJarFileURL()
Gets the URL to the JAR-file referenced by this
JarURLConnection. |
Attributes |
getMainAttributes()
Gets all attributes of the manifest file referenced by this
JarURLConnection. |
Manifest |
getManifest()
Gets the manifest file associated with this JAR-URL.
|
addRequestProperty, connect, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toStringprotected URLConnection jarFileURLConnection
protected JarURLConnection(URL url) throws MalformedURLException
JarURLConnection that refers to the
specified URL.url - the URL that contains the location to connect to.MalformedURLException - if an invalid URL has been entered.public Attributes getAttributes() throws IOException
JarEntry referenced by this JarURLConnection.JarEntry.IOException - if an I/O exception occurs while retrieving the
JAR-entries.public Certificate[] getCertificates() throws IOException
JarEntry referenced by this
JarURLConnection instance. This method will return null
until the InputStream has been completely verified.JarEntry as an array.IOException - if there is an I/O exception occurs while getting the
JarEntry.public String getEntryName()
JarURLConnection.
The return value will be null if this instance refers to a JAR
file rather than an JAR file entry.JarEntry name this instance refers to.public JarEntry getJarEntry() throws IOException
JarEntry object of the entry referenced by this JarURLConnection.JarEntry object or null if no
entry name is specified.IOException - if an error occurs while getting the file or file-entry.public Manifest getManifest() throws IOException
IOException - if an error occurs while getting the manifest file.public abstract JarFile getJarFile() throws IOException
JarFile object referenced by this JarURLConnection.IOException - if an I/O exception occurs while retrieving the JAR-file.public URL getJarFileURL()
JarURLConnection.null if there was an error
retrieving the URL.public Attributes getMainAttributes() throws IOException
JarURLConnection. If this instance refers to a JAR-file rather than a
JAR-file entry, null will be returned.null.IOException - if an I/O exception occurs while retrieving the JarFile.