org.apache.commons.io

## Class CloseableURLConnection

- java.lang.Object
- - java.net.URLConnection
  - - org.apache.commons.io.CloseableURLConnection

- All Implemented Interfaces:
    AutoCloseable

      final class CloseableURLConnection
      extends URLConnection
      implements AutoCloseable

  Delegates to a URLConnection while implementing AutoCloseable.

- - ### Field Summary

    - ### Fields inherited from class java.net.URLConnection

      `allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CloseableURLConnection(URLConnection urlConnection)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRequestProperty(String key, String value)`
    `void` | `close()`
    `void` | `connect()`
    `boolean` | `equals(Object obj)`
    `boolean` | `getAllowUserInteraction()`
    `int` | `getConnectTimeout()`
    `Object` | `getContent()`
    `Object` | `getContent(Class[] classes)`
    `String` | `getContentEncoding()`
    `int` | `getContentLength()`
    `long` | `getContentLengthLong()`
    `String` | `getContentType()`
    `long` | `getDate()`
    `boolean` | `getDefaultUseCaches()`
    `boolean` | `getDoInput()`
    `boolean` | `getDoOutput()`
    `long` | `getExpiration()`
    `String` | `getHeaderField(int n)`
    `String` | `getHeaderField(String name)`
    `long` | `getHeaderFieldDate(String name, long Default)`
    `int` | `getHeaderFieldInt(String name, int Default)`
    `String` | `getHeaderFieldKey(int n)`
    `long` | `getHeaderFieldLong(String name, long Default)`
    `Map<String,List<String>>` | `getHeaderFields()`
    `long` | `getIfModifiedSince()`
    `InputStream` | `getInputStream()`
    `long` | `getLastModified()`
    `OutputStream` | `getOutputStream()`
    `Permission` | `getPermission()`
    `int` | `getReadTimeout()`
    `Map<String,List<String>>` | `getRequestProperties()`
    `String` | `getRequestProperty(String key)`
    `URL` | `getURL()`
    `boolean` | `getUseCaches()`
    `int` | `hashCode()`
    `(package private) static CloseableURLConnection` | `open(URI uri)`
    `(package private) static CloseableURLConnection` | `open(URL url)`
    `void` | `setAllowUserInteraction(boolean allowUserInteraction)`
    `void` | `setConnectTimeout(int timeout)`
    `void` | `setDefaultUseCaches(boolean defaultUseCaches)`
    `void` | `setDoInput(boolean doInput)`
    `void` | `setDoOutput(boolean doOutput)`
    `void` | `setIfModifiedSince(long ifModifiedSince)`
    `void` | `setReadTimeout(int timeout)`
    `void` | `setRequestProperty(String key, String value)`
    `void` | `setUseCaches(boolean useCaches)`
    `String` | `toString()`

    - ### Methods inherited from class java.net.URLConnection

      `getDefaultAllowUserInteraction, getDefaultRequestProperty, getFileNameMap, guessContentTypeFromName, guessContentTypeFromStream, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setFileNameMap`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CloseableURLConnection

          CloseableURLConnection(URLConnection urlConnection)

  - ### Method Detail

    - #### addRequestProperty

          public void addRequestProperty(String key,
                                         String value)

      Overrides:
        `addRequestProperty` in class `URLConnection`

    - #### close

          public void close()

      Specified by:
        `close` in interface `AutoCloseable`

    - #### connect

          public void connect()
                       throws IOException

      Specified by:
        `connect` in class `URLConnection`
      Throws:
        `IOException`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getAllowUserInteraction

          public boolean getAllowUserInteraction()

      Overrides:
        `getAllowUserInteraction` in class `URLConnection`

    - #### getConnectTimeout

          public int getConnectTimeout()

      Overrides:
        `getConnectTimeout` in class `URLConnection`

    - #### getContent

          public Object getContent()
                            throws IOException

      Overrides:
        `getContent` in class `URLConnection`
      Throws:
        `IOException`

    - #### getContent

          public Object getContent(Class[] classes)
                            throws IOException

      Overrides:
        `getContent` in class `URLConnection`
      Throws:
        `IOException`

    - #### getContentEncoding

          public String getContentEncoding()

      Overrides:
        `getContentEncoding` in class `URLConnection`

    - #### getContentLength

          public int getContentLength()

      Overrides:
        `getContentLength` in class `URLConnection`

    - #### getContentLengthLong

          public long getContentLengthLong()

      Overrides:
        `getContentLengthLong` in class `URLConnection`

    - #### getContentType

          public String getContentType()

      Overrides:
        `getContentType` in class `URLConnection`

    - #### getDate

          public long getDate()

      Overrides:
        `getDate` in class `URLConnection`

    - #### getDefaultUseCaches

          public boolean getDefaultUseCaches()

      Overrides:
        `getDefaultUseCaches` in class `URLConnection`

    - #### getDoInput

          public boolean getDoInput()

      Overrides:
        `getDoInput` in class `URLConnection`

    - #### getDoOutput

          public boolean getDoOutput()

      Overrides:
        `getDoOutput` in class `URLConnection`

    - #### getExpiration

          public long getExpiration()

      Overrides:
        `getExpiration` in class `URLConnection`

    - #### getHeaderField

          public String getHeaderField(int n)

      Overrides:
        `getHeaderField` in class `URLConnection`

    - #### getHeaderField

          public String getHeaderField(String name)

      Overrides:
        `getHeaderField` in class `URLConnection`

    - #### getHeaderFieldDate

          public long getHeaderFieldDate(String name,
                                         long Default)

      Overrides:
        `getHeaderFieldDate` in class `URLConnection`

    - #### getHeaderFieldInt

          public int getHeaderFieldInt(String name,
                                       int Default)

      Overrides:
        `getHeaderFieldInt` in class `URLConnection`

    - #### getHeaderFieldKey

          public String getHeaderFieldKey(int n)

      Overrides:
        `getHeaderFieldKey` in class `URLConnection`

    - #### getHeaderFieldLong

          public long getHeaderFieldLong(String name,
                                         long Default)

      Overrides:
        `getHeaderFieldLong` in class `URLConnection`

    - #### getHeaderFields

          public Map<String,List<String>> getHeaderFields()

      Overrides:
        `getHeaderFields` in class `URLConnection`

    - #### getIfModifiedSince

          public long getIfModifiedSince()

      Overrides:
        `getIfModifiedSince` in class `URLConnection`

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      Overrides:
        `getInputStream` in class `URLConnection`
      Throws:
        `IOException`

    - #### getLastModified

          public long getLastModified()

      Overrides:
        `getLastModified` in class `URLConnection`

    - #### getOutputStream

          public OutputStream getOutputStream()
                                       throws IOException

      Overrides:
        `getOutputStream` in class `URLConnection`
      Throws:
        `IOException`

    - #### getPermission

          public Permission getPermission()
                                   throws IOException

      Overrides:
        `getPermission` in class `URLConnection`
      Throws:
        `IOException`

    - #### getReadTimeout

          public int getReadTimeout()

      Overrides:
        `getReadTimeout` in class `URLConnection`

    - #### getRequestProperties

          public Map<String,List<String>> getRequestProperties()

      Overrides:
        `getRequestProperties` in class `URLConnection`

    - #### getRequestProperty

          public String getRequestProperty(String key)

      Overrides:
        `getRequestProperty` in class `URLConnection`

    - #### getURL

          public URL getURL()

      Overrides:
        `getURL` in class `URLConnection`

    - #### getUseCaches

          public boolean getUseCaches()

      Overrides:
        `getUseCaches` in class `URLConnection`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### open

          static CloseableURLConnection open(URI uri)
                                      throws IOException

      Throws:
        `IOException`

    - #### open

          static CloseableURLConnection open(URL url)
                                      throws IOException

      Throws:
        `IOException`

    - #### setAllowUserInteraction

          public void setAllowUserInteraction(boolean allowUserInteraction)

      Overrides:
        `setAllowUserInteraction` in class `URLConnection`

    - #### setConnectTimeout

          public void setConnectTimeout(int timeout)

      Overrides:
        `setConnectTimeout` in class `URLConnection`

    - #### setDefaultUseCaches

          public void setDefaultUseCaches(boolean defaultUseCaches)

      Overrides:
        `setDefaultUseCaches` in class `URLConnection`

    - #### setDoInput

          public void setDoInput(boolean doInput)

      Overrides:
        `setDoInput` in class `URLConnection`

    - #### setDoOutput

          public void setDoOutput(boolean doOutput)

      Overrides:
        `setDoOutput` in class `URLConnection`

    - #### setIfModifiedSince

          public void setIfModifiedSince(long ifModifiedSince)

      Overrides:
        `setIfModifiedSince` in class `URLConnection`

    - #### setReadTimeout

          public void setReadTimeout(int timeout)

      Overrides:
        `setReadTimeout` in class `URLConnection`

    - #### setRequestProperty

          public void setRequestProperty(String key,
                                         String value)

      Overrides:
        `setRequestProperty` in class `URLConnection`

    - #### setUseCaches

          public void setUseCaches(boolean useCaches)

      Overrides:
        `setUseCaches` in class `URLConnection`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `URLConnection`