# JarURLConnection

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Fields](https://developer.android.com/reference/java/net/JarURLConnection#lfields)\|[Inherited Fields](https://developer.android.com/reference/java/net/JarURLConnection#inhfields)\|[Protected Ctors](https://developer.android.com/reference/java/net/JarURLConnection#proctors)\|[Methods](https://developer.android.com/reference/java/net/JarURLConnection#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/net/JarURLConnection#inhmethods)  

# JarURLConnection

`
public


abstract
class
JarURLConnection
`  
`


``

extends `[URLConnection](https://developer.android.com/reference/java/net/URLConnection)`


``


`

|---|---|---------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.net.URLConnection](https://developer.android.com/reference/java/net/URLConnection) ||
|   | ↳ | java.net.JarURLConnection |

<br />

*** ** * ** ***

A URL Connection to a Java ARchive (JAR) file or an entry in a JAR file.

The syntax of a JAR URL is:  

```
 jar:<url>!/{entry}
 
```

for example:

`jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class`

Jar URLs should be used to refer to a JAR file or entries in a JAR file. The example above is a JAR URL which refers to a JAR entry. If the entry name is omitted, the URL refers to the whole JAR file:`jar:http://www.foo.com/bar/baz.jar!/`

Users should cast the generic URLConnection to a JarURLConnection when they know that the URL they created is a JAR URL, and they need JAR-specific functionality. For example:  

```
 URL url = new URL("jar:file:/home/duke/duke.jar!/");
 JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
 Manifest manifest = jarConnection.getManifest();
 
```

JarURLConnection instances can only be used to read from JAR files. It is not possible to get a[OutputStream](https://developer.android.com/reference/java/io/OutputStream)to modify or write to the underlying JAR file using this class.

Examples:

A Jar entry
:   `jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class`

A Jar file
:   `jar:http://www.foo.com/bar/baz.jar!/`

A Jar directory
:   `jar:http://www.foo.com/bar/baz.jar!/COM/foo/`

`!/`is referred to as the*separator*.

When constructing a JAR url via`new URL(context, spec)`, the following rules apply:

- if there is no context URL and the specification passed to the URL constructor doesn't contain a separator, the URL is considered to refer to a JarFile.
- if there is a context URL, the context URL is assumed to refer to a JAR file or a Jar directory.
- if the specification begins with a '/', the Jar directory is ignored, and the spec is considered to be at the root of the Jar file.Examples:

  context:**jar:http://www.foo.com/bar/jar.jar!/** , spec:**baz/entry.txt**
  :   url:**jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt**

  context:**jar:http://www.foo.com/bar/jar.jar!/baz** , spec:**entry.txt**
  :   url:**jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt**

  context:**jar:http://www.foo.com/bar/jar.jar!/baz** , spec:**/entry.txt**
  :   url:**jar:http://www.foo.com/bar/jar.jar!/entry.txt**

<br />

**See also:**

- [URL](https://developer.android.com/reference/java/net/URL)
- [URLConnection](https://developer.android.com/reference/java/net/URLConnection)
- [JarFile](https://developer.android.com/reference/java/util/jar/JarFile)
- [JarInputStream](https://developer.android.com/reference/java/util/jar/JarInputStream)
- [Manifest](https://developer.android.com/reference/java/util/jar/Manifest)
- [ZipEntry](https://developer.android.com/reference/java/util/zip/ZipEntry)

## Summary

|                                                                                                                                       ### Fields                                                                                                                                       ||
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` protected `[URLConnection](https://developer.android.com/reference/java/net/URLConnection) | [jarFileURLConnection](https://developer.android.com/reference/java/net/JarURLConnection#jarFileURLConnection) The connection to the JAR file URL, if the connection has been initiated. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Inherited fields                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.net.URLConnection](https://developer.android.com/reference/java/net/URLConnection) |--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` protected boolean`                                                     | [allowUserInteraction](https://developer.android.com/reference/java/net/URLConnection#allowUserInteraction) If`true`, this`URL`is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog. | | ` protected boolean`                                                     | [connected](https://developer.android.com/reference/java/net/URLConnection#connected) If`false`, this connection object has not created a communications link to the specified URL.                                                                           | | ` protected boolean`                                                     | [doInput](https://developer.android.com/reference/java/net/URLConnection#doInput) This variable is set by the`setDoInput`method.                                                                                                                              | | ` protected boolean`                                                     | [doOutput](https://developer.android.com/reference/java/net/URLConnection#doOutput) This variable is set by the`setDoOutput`method.                                                                                                                           | | ` protected long`                                                        | [ifModifiedSince](https://developer.android.com/reference/java/net/URLConnection#ifModifiedSince) Some protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time.                           | | ` protected `[URL](https://developer.android.com/reference/java/net/URL) | [url](https://developer.android.com/reference/java/net/URLConnection#url) The URL represents the remote object on the World Wide Web to which this connection is opened.                                                                                      | | ` protected boolean`                                                     | [useCaches](https://developer.android.com/reference/java/net/URLConnection#useCaches) If`true`, the protocol is allowed to use caching whenever it can.                                                                                                       | |

|                                                                                                               ### Protected constructors                                                                                                                ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[JarURLConnection](https://developer.android.com/reference/java/net/JarURLConnection#JarURLConnection(java.net.URL))`(`[URL](https://developer.android.com/reference/java/net/URL)` url) ` Creates the new JarURLConnection to the specified URL. |

|                                                                                                                                                     ### Public methods                                                                                                                                                     ||
|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Attributes](https://developer.android.com/reference/java/util/jar/Attributes)          | ` `[getAttributes](https://developer.android.com/reference/java/net/JarURLConnection#getAttributes())`() ` Return the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise.      |
| ` `[Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate) | ` `[getCertificates](https://developer.android.com/reference/java/net/JarURLConnection#getCertificates())`() ` Return the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise. |
| ` `[String](https://developer.android.com/reference/java/lang/String)                      | ` `[getEntryName](https://developer.android.com/reference/java/net/JarURLConnection#getEntryName())`() ` Return the entry name for this connection.                                                                            |
| ` `[JarEntry](https://developer.android.com/reference/java/util/jar/JarEntry)              | ` `[getJarEntry](https://developer.android.com/reference/java/net/JarURLConnection#getJarEntry())`() ` Return the JAR entry object for this connection, if any.                                                                |
| ` abstract `[JarFile](https://developer.android.com/reference/java/util/jar/JarFile)       | ` `[getJarFile](https://developer.android.com/reference/java/net/JarURLConnection#getJarFile())`() ` Return the JAR file for this connection.                                                                                  |
| ` `[URL](https://developer.android.com/reference/java/net/URL)                             | ` `[getJarFileURL](https://developer.android.com/reference/java/net/JarURLConnection#getJarFileURL())`() ` Returns the URL for the Jar file for this connection.                                                               |
| ` `[Attributes](https://developer.android.com/reference/java/util/jar/Attributes)          | ` `[getMainAttributes](https://developer.android.com/reference/java/net/JarURLConnection#getMainAttributes())`() ` Returns the main Attributes for the JAR file for this connection.                                           |
| ` `[Manifest](https://developer.android.com/reference/java/util/jar/Manifest)              | ` `[getManifest](https://developer.android.com/reference/java/net/JarURLConnection#getManifest())`() ` Returns the Manifest for this connection, or null if none.                                                              |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.net.URLConnection](https://developer.android.com/reference/java/net/URLConnection)` ` |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                                                                                                                                                                                                         | ` `[addRequestProperty](https://developer.android.com/reference/java/net/URLConnection#addRequestProperty(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Adds a general request property specified by a key-value pair.                                                                                                                                                                   | | ` abstract void`                                                                                                                                                                                                                                                                | ` `[connect](https://developer.android.com/reference/java/net/URLConnection#connect())`() ` Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                                                                                                                                                                                      | ` `[getAllowUserInteraction](https://developer.android.com/reference/java/net/URLConnection#getAllowUserInteraction())`() ` Returns the value of the`allowUserInteraction`field for this object.                                                                                                                                                                                                                                                                                                                                           | | ` int`                                                                                                                                                                                                                                                                          | ` `[getConnectTimeout](https://developer.android.com/reference/java/net/URLConnection#getConnectTimeout())`() ` Returns setting for connect timeout.                                                                                                                                                                                                                                                                                                                                                                                       | | ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                                                                                                                                           | ` `[getContent](https://developer.android.com/reference/java/net/URLConnection#getContent())`() ` Retrieves the contents of this URL connection.                                                                                                                                                                                                                                                                                                                                                                                           | | ` `[Object](https://developer.android.com/reference/java/lang/Object)                                                                                                                                                                                                           | ` `[getContent](https://developer.android.com/reference/java/net/URLConnection#getContent(java.lang.Class[]))`(`[Class[]](https://developer.android.com/reference/java/lang/Class)` classes) ` Retrieves the contents of this URL connection.                                                                                                                                                                                                                                                                                              | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getContentEncoding](https://developer.android.com/reference/java/net/URLConnection#getContentEncoding())`() ` Returns the value of the`content-encoding`header field.                                                                                                                                                                                                                                                                                                                                                                  | | ` int`                                                                                                                                                                                                                                                                          | ` `[getContentLength](https://developer.android.com/reference/java/net/URLConnection#getContentLength())`() ` Returns the value of the`content-length`header field.                                                                                                                                                                                                                                                                                                                                                                        | | ` long`                                                                                                                                                                                                                                                                         | ` `[getContentLengthLong](https://developer.android.com/reference/java/net/URLConnection#getContentLengthLong())`() ` Returns the value of the`content-length`header field as a long.                                                                                                                                                                                                                                                                                                                                                      | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getContentType](https://developer.android.com/reference/java/net/URLConnection#getContentType())`() ` Returns the value of the`content-type`header field.                                                                                                                                                                                                                                                                                                                                                                              | | ` long`                                                                                                                                                                                                                                                                         | ` `[getDate](https://developer.android.com/reference/java/net/URLConnection#getDate())`() ` Returns the value of the`date`header field.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` static boolean`                                                                                                                                                                                                                                                               | ` `[getDefaultAllowUserInteraction](https://developer.android.com/reference/java/net/URLConnection#getDefaultAllowUserInteraction())`() ` Returns the default value of the`allowUserInteraction`field.                                                                                                                                                                                                                                                                                                                                     | | ` static `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                    | ` `[getDefaultRequestProperty](https://developer.android.com/reference/java/net/URLConnection#getDefaultRequestProperty(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` *This method was deprecated in API level 15. The instance specific getRequestProperty method should be used after an appropriate instance of URLConnection is obtained.*                                                                                                                                           | | ` boolean`                                                                                                                                                                                                                                                                      | ` `[getDefaultUseCaches](https://developer.android.com/reference/java/net/URLConnection#getDefaultUseCaches())`() ` Returns the default value of a`URLConnection`'s`useCaches`flag.                                                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                                                                                                                                                      | ` `[getDoInput](https://developer.android.com/reference/java/net/URLConnection#getDoInput())`() ` Returns the value of this`URLConnection`'s`doInput`flag.                                                                                                                                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                                                                                                                                                                                                      | ` `[getDoOutput](https://developer.android.com/reference/java/net/URLConnection#getDoOutput())`() ` Returns the value of this`URLConnection`'s`doOutput`flag.                                                                                                                                                                                                                                                                                                                                                                              | | ` long`                                                                                                                                                                                                                                                                         | ` `[getExpiration](https://developer.android.com/reference/java/net/URLConnection#getExpiration())`() ` Returns the value of the`expires`header field.                                                                                                                                                                                                                                                                                                                                                                                     | | ` static `[FileNameMap](https://developer.android.com/reference/java/net/FileNameMap)                                                                                                                                                                                           | ` `[getFileNameMap](https://developer.android.com/reference/java/net/URLConnection#getFileNameMap())`() ` Returns a[FileNameMap](https://developer.android.com/reference/java/net/FileNameMap)implementation suitable for guessing a content type based on a URL's "file" component.                                                                                                                                                                                                                                                       | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getHeaderField](https://developer.android.com/reference/java/net/URLConnection#getHeaderField(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns the value of the named header field.                                                                                                                                                                                                                                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getHeaderField](https://developer.android.com/reference/java/net/URLConnection#getHeaderField(int))`(int n) ` Returns the value for the`n`^th^header field.                                                                                                                                                                                                                                                                                                                                                                            | | ` long`                                                                                                                                                                                                                                                                         | ` `[getHeaderFieldDate](https://developer.android.com/reference/java/net/URLConnection#getHeaderFieldDate(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` name, long Default) ` Returns the value of the named field parsed as date.                                                                                                                                                                                                                                                      | | ` int`                                                                                                                                                                                                                                                                          | ` `[getHeaderFieldInt](https://developer.android.com/reference/java/net/URLConnection#getHeaderFieldInt(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int Default) ` Returns the value of the named field parsed as a number.                                                                                                                                                                                                                                                      | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getHeaderFieldKey](https://developer.android.com/reference/java/net/URLConnection#getHeaderFieldKey(int))`(int n) ` Returns the key for the`n`^th^header field.                                                                                                                                                                                                                                                                                                                                                                        | | ` long`                                                                                                                                                                                                                                                                         | ` `[getHeaderFieldLong](https://developer.android.com/reference/java/net/URLConnection#getHeaderFieldLong(java.lang.String,%20long))`(`[String](https://developer.android.com/reference/java/lang/String)` name, long Default) ` Returns the value of the named field parsed as a number.                                                                                                                                                                                                                                                  | | ` `[Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>>` | ` `[getHeaderFields](https://developer.android.com/reference/java/net/URLConnection#getHeaderFields())`() ` Returns an unmodifiable Map of the header fields.                                                                                                                                                                                                                                                                                                                                                                              | | ` long`                                                                                                                                                                                                                                                                         | ` `[getIfModifiedSince](https://developer.android.com/reference/java/net/URLConnection#getIfModifiedSince())`() ` Returns the value of this object's`ifModifiedSince`field.                                                                                                                                                                                                                                                                                                                                                                | | ` `[InputStream](https://developer.android.com/reference/java/io/InputStream)                                                                                                                                                                                                   | ` `[getInputStream](https://developer.android.com/reference/java/net/URLConnection#getInputStream())`() ` Returns an input stream that reads from this open connection.                                                                                                                                                                                                                                                                                                                                                                    | | ` long`                                                                                                                                                                                                                                                                         | ` `[getLastModified](https://developer.android.com/reference/java/net/URLConnection#getLastModified())`() ` Returns the value of the`last-modified`header field.                                                                                                                                                                                                                                                                                                                                                                           | | ` `[OutputStream](https://developer.android.com/reference/java/io/OutputStream)                                                                                                                                                                                                 | ` `[getOutputStream](https://developer.android.com/reference/java/net/URLConnection#getOutputStream())`() ` Returns an output stream that writes to this connection.                                                                                                                                                                                                                                                                                                                                                                       | | ` `[Permission](https://developer.android.com/reference/java/security/Permission)                                                                                                                                                                                               | ` `[getPermission](https://developer.android.com/reference/java/net/URLConnection#getPermission())`() ` Returns a permission object representing the permission necessary to make the connection represented by this object.                                                                                                                                                                                                                                                                                                               | | ` int`                                                                                                                                                                                                                                                                          | ` `[getReadTimeout](https://developer.android.com/reference/java/net/URLConnection#getReadTimeout())`() ` Returns setting for read timeout.                                                                                                                                                                                                                                                                                                                                                                                                | | ` `[Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>>` | ` `[getRequestProperties](https://developer.android.com/reference/java/net/URLConnection#getRequestProperties())`() ` Returns an unmodifiable Map of general request properties for this connection.                                                                                                                                                                                                                                                                                                                                       | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[getRequestProperty](https://developer.android.com/reference/java/net/URLConnection#getRequestProperty(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Returns the value of the named general request property for this connection.                                                                                                                                                                                                                                                     | | ` `[URL](https://developer.android.com/reference/java/net/URL)                                                                                                                                                                                                                  | ` `[getURL](https://developer.android.com/reference/java/net/URLConnection#getURL())`() ` Returns the value of this`URLConnection`'s`URL`field.                                                                                                                                                                                                                                                                                                                                                                                            | | ` boolean`                                                                                                                                                                                                                                                                      | ` `[getUseCaches](https://developer.android.com/reference/java/net/URLConnection#getUseCaches())`() ` Returns the value of this`URLConnection`'s`useCaches`field.                                                                                                                                                                                                                                                                                                                                                                          | | ` static `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                    | ` `[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection#guessContentTypeFromName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` fname) ` Tries to determine the content type of an object, based on the specified "file" component of a URL.                                                                                                                                                                                                                | | ` static `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                    | ` `[guessContentTypeFromStream](https://developer.android.com/reference/java/net/URLConnection#guessContentTypeFromStream(java.io.InputStream))`(`[InputStream](https://developer.android.com/reference/java/io/InputStream)` is) ` Tries to determine the type of an input stream based on the characters at the beginning of the input stream.                                                                                                                                                                                           | | ` void`                                                                                                                                                                                                                                                                         | ` `[setAllowUserInteraction](https://developer.android.com/reference/java/net/URLConnection#setAllowUserInteraction(boolean))`(boolean allowuserinteraction) ` Set the value of the`allowUserInteraction`field of this`URLConnection`.                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                                                                                                                                                                                                         | ` `[setConnectTimeout](https://developer.android.com/reference/java/net/URLConnection#setConnectTimeout(int))`(int timeout) ` Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.                                                                                                                                                                                                                                                             | | ` static void`                                                                                                                                                                                                                                                                  | ` `[setContentHandlerFactory](https://developer.android.com/reference/java/net/URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory))`(`[ContentHandlerFactory](https://developer.android.com/reference/java/net/ContentHandlerFactory)` fac) ` Sets the`ContentHandlerFactory`of an application.                                                                                                                                                                                                                         | | ` static void`                                                                                                                                                                                                                                                                  | ` `[setDefaultAllowUserInteraction](https://developer.android.com/reference/java/net/URLConnection#setDefaultAllowUserInteraction(boolean))`(boolean defaultallowuserinteraction) ` Sets the default value of the`allowUserInteraction`field for all future`URLConnection`objects to the specified value.                                                                                                                                                                                                                                  | | ` static void`                                                                                                                                                                                                                                                                  | ` `[setDefaultRequestProperty](https://developer.android.com/reference/java/net/URLConnection#setDefaultRequestProperty(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` *This method was deprecated in API level 15. The instance specific setRequestProperty method should be used after an appropriate instance of URLConnection is obtained. Invoking this method will have no effect.* | | ` void`                                                                                                                                                                                                                                                                         | ` `[setDefaultUseCaches](https://developer.android.com/reference/java/net/URLConnection#setDefaultUseCaches(boolean))`(boolean defaultusecaches) ` Sets the default value of the`useCaches`field to the specified value.                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                                                                                                                                         | ` `[setDoInput](https://developer.android.com/reference/java/net/URLConnection#setDoInput(boolean))`(boolean doinput) ` Sets the value of the`doInput`field for this`URLConnection`to the specified value.                                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                                                                                                                                         | ` `[setDoOutput](https://developer.android.com/reference/java/net/URLConnection#setDoOutput(boolean))`(boolean dooutput) ` Sets the value of the`doOutput`field for this`URLConnection`to the specified value.                                                                                                                                                                                                                                                                                                                             | | ` static void`                                                                                                                                                                                                                                                                  | ` `[setFileNameMap](https://developer.android.com/reference/java/net/URLConnection#setFileNameMap(java.net.FileNameMap))`(`[FileNameMap](https://developer.android.com/reference/java/net/FileNameMap)` map) ` Sets the FileNameMap.                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                                                                                                                                         | ` `[setIfModifiedSince](https://developer.android.com/reference/java/net/URLConnection#setIfModifiedSince(long))`(long ifmodifiedsince) ` Sets the value of the`ifModifiedSince`field of this`URLConnection`to the specified value.                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                                                                                                                                         | ` `[setReadTimeout](https://developer.android.com/reference/java/net/URLConnection#setReadTimeout(int))`(int timeout) ` Sets the read timeout to a specified timeout, in milliseconds.                                                                                                                                                                                                                                                                                                                                                     | | ` void`                                                                                                                                                                                                                                                                         | ` `[setRequestProperty](https://developer.android.com/reference/java/net/URLConnection#setRequestProperty(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Sets the general request property.                                                                                                                                                                                               | | ` void`                                                                                                                                                                                                                                                                         | ` `[setUseCaches](https://developer.android.com/reference/java/net/URLConnection#setUseCaches(boolean))`(boolean usecaches) ` Sets the value of the`useCaches`field of this`URLConnection`to the specified value.                                                                                                                                                                                                                                                                                                                          | | ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                                                                           | ` `[toString](https://developer.android.com/reference/java/net/URLConnection#toString())`() ` Returns a`String`representation of this URL connection.                                                                                                                                                                                                                                                                                                                                                                                      | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Fields

### jarFileURLConnection

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected URLConnection jarFileURLConnection
```

The connection to the JAR file URL, if the connection has been initiated. This should be set by connect.

<br />

## Protected constructors

### JarURLConnection

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected JarURLConnection (URL url)
```

Creates the new JarURLConnection to the specified URL.

<br />

|          Parameters          ||
|-------|-----------------------|
| `url` | `URL`: the URL <br /> |

|                                                                                              Throws                                                                                               ||
|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [MalformedURLException](https://developer.android.com/reference/java/net/MalformedURLException) | if no legal protocol could be found in a specification string or the string could not be parsed. |

## Public methods

### getAttributes

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Attributes getAttributes ()
```

Return the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise.

<br />

|                                                                                            Returns                                                                                             ||
|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| [Attributes](https://developer.android.com/reference/java/util/jar/Attributes) | the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise. <br /> |

|                                                                  Throws                                                                  ||
|----------------------------------------------------------------------------|--------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if getting the JAR entry causes an IOException to be thrown. |

**See also:**

- [getJarEntry()](https://developer.android.com/reference/java/net/JarURLConnection#getJarEntry())  

### getCertificates

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Certificate[] getCertificates ()
```

Return the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise. This method can only be called once the connection has been completely verified by reading from the input stream until the end of the stream has been reached. Otherwise, this method will return`null`

<br />

|                                                                                                 Returns                                                                                                  ||
|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| [Certificate[]](https://developer.android.com/reference/java/security/cert/Certificate) | the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise. <br /> |

|                                                                  Throws                                                                  ||
|----------------------------------------------------------------------------|--------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if getting the JAR entry causes an IOException to be thrown. |

**See also:**

- [getJarEntry()](https://developer.android.com/reference/java/net/JarURLConnection#getJarEntry())  

### getEntryName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getEntryName ()
```

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

<br />

|                                                        Returns                                                         ||
|--------------------------------------------------------------------|----------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the entry name for this connection, if any. <br /> |

### getJarEntry

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public JarEntry 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.

<br />

|                                                                                            Returns                                                                                            ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [JarEntry](https://developer.android.com/reference/java/util/jar/JarEntry) | the JAR entry object for this connection, or null if the JAR URL for this connection points to a JAR file. <br /> |

|                                                                           Throws                                                                            ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if getting the JAR file for this connection causes an IOException to be thrown. |

**See also:**

- [getJarFile()](https://developer.android.com/reference/java/net/JarURLConnection#getJarFile())
- [getJarEntry()](https://developer.android.com/reference/java/net/JarURLConnection#getJarEntry())  

### getJarFile

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract JarFile getJarFile ()
```

Return the JAR file for this connection.

<br />

|                                                                                                     Returns                                                                                                     ||
|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| [JarFile](https://developer.android.com/reference/java/util/jar/JarFile) | the JAR file for this connection. If the connection is a connection to an entry of a JAR file, the JAR file object is returned <br /> |

|                                                                              Throws                                                                               ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if an IOException occurs while trying to connect to the JAR file for this connection. |

**See also:**

- [URLConnection.connect()](https://developer.android.com/reference/java/net/URLConnection#connect())  

### getJarFileURL

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public URL getJarFileURL ()
```

Returns the URL for the Jar file for this connection.

<br />

|                                                      Returns                                                      ||
|-------------------------------------------------------------|------------------------------------------------------|
| [URL](https://developer.android.com/reference/java/net/URL) | the URL for the Jar file for this connection. <br /> |

### getMainAttributes

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Attributes getMainAttributes ()
```

Returns the main Attributes for the JAR file for this connection.

<br />

|                                                                     Returns                                                                      ||
|--------------------------------------------------------------------------------|------------------------------------------------------------------|
| [Attributes](https://developer.android.com/reference/java/util/jar/Attributes) | the main Attributes for the JAR file for this connection. <br /> |

|                                                                 Throws                                                                  ||
|----------------------------------------------------------------------------|-------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if getting the manifest causes an IOException to be thrown. |

**See also:**

- [getJarFile()](https://developer.android.com/reference/java/net/JarURLConnection#getJarFile())
- [getManifest()](https://developer.android.com/reference/java/net/JarURLConnection#getManifest())  

### getManifest

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Manifest getManifest ()
```

Returns the Manifest for this connection, or null if none.

<br />

|                                                                             Returns                                                                              ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [Manifest](https://developer.android.com/reference/java/util/jar/Manifest) | the manifest object corresponding to the JAR file object for this connection. <br /> |

|                                                                           Throws                                                                            ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if getting the JAR file for this connection causes an IOException to be thrown. |

**See also:**

- [getJarFile()](https://developer.android.com/reference/java/net/JarURLConnection#getJarFile())