public class NestedJarURLConnection extends URLConnection
It is expected that the outer JAR is available on the local filesystem and accessible via standard java.io.File operations.
This class knows how to handle URLs using a custom nestedjar protocol. The URL should be of the form:
nestedjar://file:/C:/TEMP/apps.jar!/innerapps.jar!/myapp/nested.gif
The different parts of the URL are:nestedjar:// | Custom protocol for loading resources from nested jar files. |
/C:/TEMP/ | Path to the toplevel jar file. Should be accessible via standard java.io.File. |
apps.jar | Outer jar file. This jar file is on the classpath. It contains nested jar file(s). |
innerapps.jar | Jar file nested inside the outer jar file. This Jar file contains the actual resources. |
myapp/nested.gif | Resource in the inner jar file that is to be loaded |
!/ | Separator. Separates a jar file and the components it contains. |
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
Constructor and Description |
---|
NestedJarURLConnection(URL url)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Opens a communications link to the resource referenced by this
URL, if such a connection has not already been established.
|
String |
getContentType()
Determine the content type of the resource
|
InputStream |
getInputStream()
Returns an input stream that reads from this open connection.
|
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
public NestedJarURLConnection(URL url)
public void connect() throws IOException
If the connect
method is called when the connection
has already been opened the call is ignored.
connect
in class URLConnection
IOException
- if an I/O error occurs while opening the
connection.public InputStream getInputStream() throws IOException
getInputStream
in class URLConnection
IOException
- if an I/O error occurs while
creating the input stream.UnknownServiceException
- if the protocol does not support
input.public String getContentType()
getContentType
in class URLConnection
Copyright © 2003, 2023, Oracle and/or its affiliates.