Reads characters from an input character stream. This implementation guarantees that it will read as many characters as possible before giving up; this may not always be the case for subclasses of Reader. @param input where to read input from @param buffer destination @param offset initial
(final Reader input, final char[] buffer, final int offset, final int length)
| 2852 | * @since 2.2 |
| 2853 | */ |
| 2854 | public static int read(final Reader input, final char[] buffer, final int offset, final int length) |
| 2855 | throws IOException { |
| 2856 | if (length < 0) { |
| 2857 | throw new IllegalArgumentException("Length must not be negative: " + length); |
| 2858 | } |
| 2859 | int remaining = length; |
| 2860 | while (remaining > 0) { |
| 2861 | final int location = length - remaining; |
| 2862 | final int count = input.read(buffer, offset + location, remaining); |
| 2863 | if (EOF == count) { // EOF |
| 2864 | break; |
| 2865 | } |
| 2866 | remaining -= count; |
| 2867 | } |
| 2868 | return length - remaining; |
| 2869 | } |
| 2870 | |
| 2871 | /** |
| 2872 | * Reads characters from an input character stream. |
no outgoing calls