- 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.ReaderA 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 voidclose()java.nio.charset.CharsetgetCharset()Charset used by this readerjava.net.URLgetURL()URL of this readerintread(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:
readin classjava.io.Reader- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein 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
-
-