@Override public boolean ready() throws IOException { synchronized (lock) { ensureOpen(); return true; } }
@Override public void reset() throws IOException { synchronized (lock) { ensureOpen(); next = mark; } }
@Override public void reset() throws IOException { synchronized (lock) { ensureOpen(); next = mark; } }
@Override public boolean ready() throws IOException { synchronized (lock) { ensureOpen(); return true; } }
@Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } synchronized (lock) { ensureOpen(); mark = next; } }
@Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } synchronized (lock) { ensureOpen(); mark = next; } }
@Override public int read() throws IOException { synchronized (lock) { ensureOpen(); if (next >= length) { return -1; } return seq.charAt(next++); } }
@Override public int read() throws IOException { synchronized (lock) { ensureOpen(); if (next >= length) { return -1; } return seq.charAt(next++); } }
@Override public long skip(long ns) throws IOException { synchronized (lock) { ensureOpen(); if (next >= length) { return 0; } // Bound skip by beginning and end of the source long n = Math.min(length - next, ns); n = Math.max(-next, n); next += n; return n; } }
@Override public long skip(long ns) throws IOException { synchronized (lock) { ensureOpen(); if (next >= length) { return 0; } // Bound skip by beginning and end of the source long n = Math.min(length - next, ns); n = Math.max(-next, n); next += n; return n; } }
@Override public int read(char[] cbuf, int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) { return -1; } int n = Math.min(length - next, len); // this was adapted from the original StringReader code. for (int i = 0; i < n; i++) { cbuf[off + i] = seq.charAt(next + i); } next += n; return n; } }
@Override public int read(char[] cbuf, int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) { return -1; } int n = Math.min(length - next, len); // this was adapted from the original StringReader code. for (int i = 0; i < n; i++) { cbuf[off + i] = seq.charAt(next + i); } next += n; return n; } }