@Override public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (!ensureInput()) { return -1; } int n = Math.min(len, buffer.length - cursor); for (int i = 0; i < n; ++i) { b[off + i] = buffer[cursor + i]; } if (n < len) { b[off + n++] = '\n'; } cursor += n; return n; }
@Override public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (!ensureInput()) { return -1; } int n = Math.min(len, buffer.length - cursor); for (int i = 0; i < n; ++i) { b[off + i] = buffer[cursor + i]; } if (n < len) { b[off + n++] = '\n'; } cursor += n; return n; }
private boolean ensureInput() throws IOException { if (atEOF) { return false; } if (cursor < 0 || cursor > buffer.length) { if (readNextLine() == -1) { atEOF = true; return false; } cursor = 0; } return true; }
private boolean ensureInput() throws IOException { if (atEOF) { return false; } if (cursor < 0 || cursor > buffer.length) { if (readNextLine() == -1) { atEOF = true; return false; } cursor = 0; } return true; }
JLineShellConsoleV1(Object reader, Charset cs) { this.reader = reader; this.in = new ConsoleInputStream(this, cs); }
JLineShellConsoleV2(Object reader, Charset cs) { this.reader = reader; this.in = new ConsoleInputStream(this, cs); }
JLineShellConsoleV2(Object reader, Charset cs) { this.reader = reader; this.in = new ConsoleInputStream(this, cs); }
@Override public synchronized int read() throws IOException { if (!ensureInput()) { return -1; } if (cursor == buffer.length) { cursor++; return '\n'; } return buffer[cursor++]; }
JLineShellConsoleV1(Object reader, Charset cs) { this.reader = reader; this.in = new ConsoleInputStream(this, cs); }
@Override public synchronized int read() throws IOException { if (!ensureInput()) { return -1; } if (cursor == buffer.length) { cursor++; return '\n'; } return buffer[cursor++]; }