- java.lang.Object
-
- java.io.Reader
-
- org.openjdk.nashorn.api.scripting.URLReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public final class URLReader extends java.io.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.nio.charset.Charset
getCharset()
Charset used by this readerjava.net.URL
getURL()
URL of this readerint
read(char[] cbuf, int off, int len)
-
-
-
Constructor Detail
-
URLReader
public URLReader(java.net.URL url)
Constructor- Parameters:
url
- URL for this URLReader- Throws:
java.lang.NullPointerException
- if url is null
-
URLReader
public URLReader(java.net.URL url, java.lang.String charsetName)
Constructor- Parameters:
url
- URL for this URLReadercharsetName
- Name of the Charset used to convert bytes to chars- Throws:
java.lang.NullPointerException
- if url is null
-
URLReader
public URLReader(java.net.URL url, java.nio.charset.Charset cs)
Constructor- Parameters:
url
- URL for this URLReadercs
- Charset used to convert bytes to chars- Throws:
java.lang.NullPointerException
- if url is null
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
getURL
public java.net.URL getURL()
URL of this reader- Returns:
- the URL from which this reader reads.
-
getCharset
public java.nio.charset.Charset getCharset()
Charset used by this reader- Returns:
- the Charset used to convert bytes to chars
-
-