{@inheritDoc} @since 2018/11/04
(char[] __c, int __o, int __l)
| 2258 | * @since 2018/11/04 |
| 2259 | */ |
| 2260 | @Override |
| 2261 | public int read(char[] __c, int __o, int __l) |
| 2262 | throws IndexOutOfBoundsException, NullPointerException |
| 2263 | { |
| 2264 | if (__c == null) |
| 2265 | throw new NullPointerException("NARG"); |
| 2266 | if (__o < 0 || __l < 0 || (__o + __l) > __c.length) |
| 2267 | throw new IndexOutOfBoundsException("IOOB"); |
| 2268 | |
| 2269 | // Determine the current position and string length |
| 2270 | int at = this._at, |
| 2271 | length = this.length, |
| 2272 | left = length - at; |
| 2273 | |
| 2274 | // EOF? |
| 2275 | if (at >= length) |
| 2276 | return -1; |
| 2277 | |
| 2278 | // Can only read so many characters |
| 2279 | String string = this.string; |
| 2280 | int max = Math.min(__l, left), |
| 2281 | limit = at + max; |
| 2282 | for (int o = __o; at < limit; at++, o++) |
| 2283 | __c[o] = string.charAt(at); |
| 2284 | |
| 2285 | // Set position for next time |
| 2286 | this._at = at; |
| 2287 | |
| 2288 | return max; |
| 2289 | } |
| 2290 | } |
| 2291 | } |
| 2292 |