compact1, compact2, compact3
jdk.nashorn.api.scripting

## Class URLReader

- java.lang.Object
- - java.io.Reader
  - - jdk.nashorn.api.scripting.URLReader

All Implemented Interfaces:
  Closeable, AutoCloseable, Readable

    @Exported
    public final class URLReader
    extends Reader

A Reader that reads from a URL. Used to make sure that the reader reads content from given URL and can be trusted to do so.

Since:
  1.8u40

### Field Summary

### Fields inherited from class java.io.Reader

`lock`

### Constructor Summary

Constructors
Constructor and Description
`URLReader(URL url)` Constructor
`URLReader(URL url, Charset cs)` Constructor
`URLReader(URL url, String charsetName)` Constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Closes the stream and releases any system resources associated with it.
`Charset` `getCharset()` Charset used by this reader
`URL` `getURL()` URL of this reader
`int` `read(char[] cbuf, int off, int len)` Reads characters into a portion of an array.

### Methods inherited from class java.io.Reader

`mark, markSupported, read, read, read, ready, reset, skip`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### URLReader

    public URLReader(URL url)

Constructor

Parameters:
  `url` - URL for this URLReader
Throws:
  `NullPointerException` - if url is null

#### URLReader

    public URLReader(URL url,
                     String charsetName)

Constructor

Parameters:
  `url` - URL for this URLReader
  `charsetName` - Name of the Charset used to convert bytes to chars
Throws:
  `NullPointerException` - if url is null

#### URLReader

    public URLReader(URL url,
                     Charset cs)

Constructor

Parameters:
  `url` - URL for this URLReader
  `cs` - Charset used to convert bytes to chars
Throws:
  `NullPointerException` - if url is null

### Method Detail

#### read

    public int read(char[] cbuf,
                    int off,
                    int len)
             throws IOException

Description copied from class: `java.io.Reader`
Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Specified by:
  `read` in class `Reader`
Parameters:
  `cbuf` - Destination buffer
  `off` - Offset at which to start storing characters
  `len` - Maximum number of characters to read
Returns:
  The number of characters read, or -1 if the end of the stream has been reached
Throws:
  `IOException` - If an I/O error occurs

#### close

    public void close()
               throws IOException

Description copied from class: `java.io.Reader`
Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in class `Reader`
Throws:
  `IOException` - If an I/O error occurs

#### getURL

    public URL getURL()

URL of this reader

Returns:
  the URL from which this reader reads.

#### getCharset

    public Charset getCharset()

Charset used by this reader

Returns:
  the Charset used to convert bytes to chars