61
62 /**
63 * Constructor
64 *
65 * @param url URL for this URLReader
66 * @param charsetName Name of the Charset used to convert bytes to chars
67 * @throws NullPointerException if url is null
68 */
69 public URLReader(final URL url, final String charsetName) {
70 this(url, Charset.forName(charsetName));
71 }
72
73 /**
74 * Constructor
75 *
76 * @param url URL for this URLReader
77 * @param cs Charset used to convert bytes to chars
78 * @throws NullPointerException if url is null
79 */
80 public URLReader(final URL url, final Charset cs) {
81 Objects.requireNonNull(url);
82 this.url = url;
83 this.cs = cs;
84 }
85
86 @Override
87 public int read(final char cbuf[], final int off, final int len) throws IOException {
88 return getReader().read(cbuf, off, len);
89 }
90
91 @Override
92 public void close() throws IOException {
93 getReader().close();
94 }
95
96 /**
97 * URL of this reader
98 * @return the URL from which this reader reads.
99 */
100 public URL getURL() {
101 return url;
102 }
|
61
62 /**
63 * Constructor
64 *
65 * @param url URL for this URLReader
66 * @param charsetName Name of the Charset used to convert bytes to chars
67 * @throws NullPointerException if url is null
68 */
69 public URLReader(final URL url, final String charsetName) {
70 this(url, Charset.forName(charsetName));
71 }
72
73 /**
74 * Constructor
75 *
76 * @param url URL for this URLReader
77 * @param cs Charset used to convert bytes to chars
78 * @throws NullPointerException if url is null
79 */
80 public URLReader(final URL url, final Charset cs) {
81 this.url = Objects.requireNonNull(url);
82 this.cs = cs;
83 }
84
85 @Override
86 public int read(final char cbuf[], final int off, final int len) throws IOException {
87 return getReader().read(cbuf, off, len);
88 }
89
90 @Override
91 public void close() throws IOException {
92 getReader().close();
93 }
94
95 /**
96 * URL of this reader
97 * @return the URL from which this reader reads.
98 */
99 public URL getURL() {
100 return url;
101 }
|