APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.net.www.protocol.jar

public Class JarURLConnection

extends JarURLConnection
Class Inheritance
Imports
sun.net.www.protocol.file.FileURLConnection, java.io.BufferedInputStream, .FileNotFoundException, .IOException, .InputStream, java.net.MalformedURLException, .URL, java.security.Permission, java.util.List, .Map, java.util.jar.JarEntry, .JarFile

Author
Benjamin Renaud
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private String
private static final JarFileFactory
private JarEntry
private JarFile
Inherited from java.net.JarURLConnection:
jarFileURLConnection

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addRequestProperty(String
the keyword by which the request is known (e.g., "accept").
key
,
String
the value associated with it.
value
)

Overrides java.net.URLConnection.addRequestProperty.

Adds a general request property specified by a key-value pair.

public void
connect()

Implements abstract java.net.URLConnection.connect.

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

public boolean

Returns:

the value of the allowUserInteraction field for this object.
getAllowUserInteraction
()

Overrides java.net.URLConnection.getAllowUserInteraction.

Returns the value of the allowUserInteraction field for this object.

public Object
getContent()

Overrides java.net.URLConnection.getContent.

Retrieves the contents of this URL connection.

public int
getContentLength()

Overrides java.net.URLConnection.getContentLength.

Returns the value of the content-length header field.

public long
getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.

public String
getContentType()

Overrides java.net.URLConnection.getContentType.

Returns the value of the content-type header field.

public boolean

Returns:

the default value of a URLConnection's useCaches flag.
getDefaultUseCaches
()

Overrides java.net.URLConnection.getDefaultUseCaches.

Returns the default value of a URLConnection's useCaches flag.

public String
getHeaderField(String name)

Overrides java.net.URLConnection.getHeaderField.

Returns the value of the named header field.

public InputStream
getInputStream()

Overrides java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection.

public JarEntry
getJarEntry()

Overrides java.net.JarURLConnection.getJarEntry.

Return the JAR entry object for this connection, if any.

public JarFile
getJarFile()

Implements abstract java.net.JarURLConnection.getJarFile.

Return the JAR file for this connection.

public Permission
getPermission()

Overrides java.net.URLConnection.getPermission.

Deprecated for removal since 25.

Returns a permission object representing the permission necessary to make the connection represented by this object.

public Map<String, List<String>>

Returns:

a Map of the general request properties for this connection.
getRequestProperties
()

Overrides java.net.URLConnection.getRequestProperties.

Returns an unmodifiable Map of general request properties for this connection.

public String

Returns:

the value of the named general request property for this connection.
getRequestProperty
(String key)

Overrides java.net.URLConnection.getRequestProperty.

Returns the value of the named general request property for this connection.

public boolean

Returns:

the value of this URLConnection's useCaches field.
getUseCaches
()

Overrides java.net.URLConnection.getUseCaches.

Returns the value of this URLConnection's useCaches field.

public void
setAllowUserInteraction(boolean
the new value.
allowuserinteraction
)

Overrides java.net.URLConnection.setAllowUserInteraction.

Set the value of the allowUserInteraction field of this URLConnection.

public void
setDefaultUseCaches(boolean
the new value.
defaultusecaches
)

Overrides java.net.URLConnection.setDefaultUseCaches.

Sets the default value of the useCaches field to the specified value.

public void
setIfModifiedSince(long
the new value.
ifmodifiedsince
)

Overrides java.net.URLConnection.setIfModifiedSince.

Sets the value of the ifModifiedSince field of this URLConnection to the specified value.

public void
setRequestProperty(String
the keyword by which the request is known (e.g., "accept").
key
,
String
the value associated with it.
value
)

Overrides java.net.URLConnection.setRequestProperty.

Sets the general request property.

public void
setUseCaches(boolean usecaches)

Overrides java.net.URLConnection.setUseCaches.

Sets the value of the useCaches field of this URLConnection to the specified value.

Inherited from java.net.JarURLConnection:
getAttributesgetCertificatesgetEntryNamegetJarFileURLgetMainAttributesgetManifest

Field Detail

contentTypeback to summary
private String contentType
factoryback to summary
private static final JarFileFactory factory

Hides java.net.URLConnection.factory.

jarEntryback to summary
private JarEntry jarEntry
jarFileback to summary
private JarFile jarFile

Constructor Detail

JarURLConnectionback to summary
public JarURLConnection(URL url, Handler handler) throws MalformedURLException, IOException

Method Detail

addRequestPropertyback to summary
public void addRequestProperty(String key, String value)

Overrides java.net.URLConnection.addRequestProperty.

Adds a general request property specified by a key-value pair. This method will not overwrite existing values associated with the same key.

Parameters
key:String

the keyword by which the request is known (e.g., "accept").

value:String

the value associated with it.

connectback to summary
public void connect() throws IOException

Implements abstract java.net.URLConnection.connect.

Doc from java.net.URLConnection.connect.

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

If the connect method is called when the connection has already been opened (indicated by the connected field having the value true), the call is ignored.

URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.

Exceptions
IOException:
if an I/O error occurs while opening the connection.
getAllowUserInteractionback to summary
public boolean getAllowUserInteraction()

Overrides java.net.URLConnection.getAllowUserInteraction.

Returns the value of the allowUserInteraction field for this object.

Returns:boolean

the value of the allowUserInteraction field for this object.

See Also
java.net.URLConnection#allowUserInteraction
getContentback to summary
public Object getContent() throws IOException

Overrides java.net.URLConnection.getContent.

Doc from java.net.URLConnection.getContent.

Retrieves the contents of this URL connection.

This method first determines the content type of the object by calling the getContentType method. If this is the first time that the application has seen that specific content type, a content handler for that content type is created.

This is done as follows:

  1. If the application has set up a content handler factory instance using the setContentHandlerFactory method, the createContentHandler method of that instance is called with the content type as an argument; the result is a content handler for that content type.
  2. If no ContentHandlerFactory has yet been set up, or if the factory's createContentHandler method returns null, then the ServiceLoader mechanism is used to locate ContentHandlerFactory implementations using the system class loader. The order that factories are located is implementation specific, and an implementation is free to cache the located factories. A ServiceConfigurationError, Error or RuntimeException thrown from the createContentHandler, if encountered, will be propagated to the calling thread. The createContentHandler method of each factory, if instantiated, is invoked, with the content type, until a factory returns non-null, or all factories have been exhausted.
  3. Failing that, this method tries to load a content handler class as defined by ContentHandler. If the class does not exist, or is not a subclass of ContentHandler, then an UnknownServiceException is thrown.
Exceptions
IOException:
if an I/O error occurs while getting the content.
getContentLengthback to summary
public int getContentLength()

Overrides java.net.URLConnection.getContentLength.

Doc from java.net.URLConnection.getContentLength.

Returns the value of the content-length header field.

Note

getContentLengthLong() should be preferred over this method, since it returns a long instead and is therefore more portable.

getContentLengthLongback to summary
public long getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Doc from java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.

getContentTypeback to summary
public String getContentType()

Overrides java.net.URLConnection.getContentType.

Doc from java.net.URLConnection.getContentType.

Returns the value of the content-type header field.

getDefaultUseCachesback to summary
public boolean getDefaultUseCaches()

Overrides java.net.URLConnection.getDefaultUseCaches.

Returns the default value of a URLConnection's useCaches flag.

The default is "sticky", being a part of the static state of all URLConnections. This flag applies to the next, and all following URLConnections that are created.

Returns:boolean

the default value of a URLConnection's useCaches flag.

See Also
java.net.URLConnection#useCaches
getHeaderFieldback to summary
public String getHeaderField(String name)

Overrides java.net.URLConnection.getHeaderField.

Doc from java.net.URLConnection.getHeaderField.

Returns the value of the named header field.

If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides java.net.URLConnection.getInputStream.

Doc from java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read.

Exceptions
IOException:
if an I/O error occurs while creating the input stream.
getJarEntryback to summary
public JarEntry getJarEntry() throws IOException

Overrides java.net.JarURLConnection.getJarEntry.

Doc from java.net.JarURLConnection.getJarEntry.

Return the JAR entry object for this connection, if any. This method returns null if the JAR file URL corresponding to this connection points to a JAR file and not a JAR file entry.

Exceptions
IOException:
if getting the JAR file for this connection causes an IOException to be thrown.
getJarFileback to summary
public JarFile getJarFile() throws IOException

Implements abstract java.net.JarURLConnection.getJarFile.

Doc from java.net.JarURLConnection.getJarFile.

Return the JAR file for this connection.

Exceptions
IOException:
if an IOException occurs while trying to connect to the JAR file for this connection.
getPermissionback to summary
public Permission getPermission() throws IOException

Overrides java.net.URLConnection.getPermission.

Doc from java.net.URLConnection.getPermission.

Deprecated

for removal since 25.

Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns java.security.AllPermission. Subclasses should override this method and return the permission that best represents the permission required to make a connection to the URL. For example, a URLConnection representing a file: URL would return a java.io.FilePermission object.

The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.

Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained after the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested before connecting.

Annotations
@Override
@Deprecated
since:25
forRemoval:true
@SuppressWarnings:removal
Exceptions
IOException:
if the computation of the permission requires network or file I/O and an exception occurs while computing it.
getRequestPropertiesback to summary
public Map<String, List<String>> getRequestProperties()

Overrides java.net.URLConnection.getRequestProperties.

Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names. Each Map value is a unmodifiable List of Strings that represents the corresponding field values.

Returns:Map<String, List<String>>

a Map of the general request properties for this connection.

getRequestPropertyback to summary
public String getRequestProperty(String key)

Overrides java.net.URLConnection.getRequestProperty.

Returns the value of the named general request property for this connection.

Returns:String

the value of the named general request property for this connection.

getUseCachesback to summary
public boolean getUseCaches()

Overrides java.net.URLConnection.getUseCaches.

Returns the value of this URLConnection's useCaches field.

Returns:boolean

the value of this URLConnection's useCaches field.

See Also
java.net.URLConnection#useCaches
setAllowUserInteractionback to summary
public void setAllowUserInteraction(boolean allowuserinteraction)

Overrides java.net.URLConnection.setAllowUserInteraction.

Set the value of the allowUserInteraction field of this URLConnection.

Parameters
allowuserinteraction:boolean

the new value.

See Also
java.net.URLConnection#allowUserInteraction
setDefaultUseCachesback to summary
public void setDefaultUseCaches(boolean defaultusecaches)

Overrides java.net.URLConnection.setDefaultUseCaches.

Sets the default value of the useCaches field to the specified value.

Parameters
defaultusecaches:boolean

the new value.

See Also
java.net.URLConnection#useCaches
setIfModifiedSinceback to summary
public void setIfModifiedSince(long ifmodifiedsince)

Overrides java.net.URLConnection.setIfModifiedSince.

Sets the value of the ifModifiedSince field of this URLConnection to the specified value.

Parameters
ifmodifiedsince:long

the new value.

See Also
java.net.URLConnection#ifModifiedSince
setRequestPropertyback to summary
public void setRequestProperty(String key, String value)

Overrides java.net.URLConnection.setRequestProperty.

Sets the general request property.

Parameters
key:String

the keyword by which the request is known (e.g., "accept").

value:String

the value associated with it.

setUseCachesback to summary
public void setUseCaches(boolean usecaches)

Overrides java.net.URLConnection.setUseCaches.

Sets the value of the useCaches field of this URLConnection to the specified value.

Some protocols do caching of documents. Occasionally, it is important to be able to "tunnel through" and ignore the caches (e.g., the "reload" button in a browser). If the UseCaches flag on a connection is true, the connection is allowed to use whatever caches it can. If false, caches are to be ignored. The default value comes from DefaultUseCaches, which defaults to true.

See Also
java.net.URLConnection#useCaches
sun.net.www.protocol.jar back to summary

pack-priv Class JarURLConnection.JarURLInputStream

extends FilterInputStream
Class Inheritance

Field Summary

Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

Inherited from java.io.FilterInputStream:
availablemarkmarkSupportedreadreadreadresetskip

Constructor Detail

JarURLInputStreamback to summary
pack-priv JarURLInputStream(InputStream src)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterInputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.