Class URLReader

java.lang.Object
java.io.Reader
org.openjdk.nashorn.api.scripting.URLReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

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
  • Constructor Details

    • 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 Details

    • read

      public int read(char[] cbuf, int off, int len) throws IOException
      Specified by:
      read in class Reader
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
      Throws:
      IOException
    • 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