| 13 | import java.nio.CharBuffer; |
| 14 | |
| 15 | public abstract class Reader implements Closeable, Readable { |
| 16 | public int read(CharBuffer buffer) throws IOException { |
| 17 | int c = read(buffer.array(), |
| 18 | buffer.arrayOffset() + buffer.position(), |
| 19 | buffer.remaining()); |
| 20 | |
| 21 | if (c > 0) { |
| 22 | buffer.position(buffer.position() + c); |
| 23 | } |
| 24 | |
| 25 | return c; |
| 26 | } |
| 27 | |
| 28 | public int read() throws IOException { |
| 29 | char[] buffer = new char[1]; |
| 30 | int c = read(buffer); |
| 31 | if (c <= 0) { |
| 32 | return -1; |
| 33 | } else { |
| 34 | return (int) buffer[0]; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public int read(char[] buffer) throws IOException { |
| 39 | return read(buffer, 0, buffer.length); |
| 40 | } |
| 41 | |
| 42 | public abstract int read(char[] buffer, int offset, int length) |
| 43 | throws IOException; |
| 44 | |
| 45 | public boolean markSupported() { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | public void mark(int readAheadLimit) throws IOException { |
| 50 | throw new IOException("mark not supported"); |
| 51 | } |
| 52 | |
| 53 | public void reset() throws IOException { |
| 54 | throw new IOException("reset not supported"); |
| 55 | } |
| 56 | |
| 57 | public abstract void close() throws IOException; |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected