@Override public final void flush() throws IOException { if (closed) { throw new IOException("Stream is closed"); } flushBuffer(); }
@Override public void write(int b) throws IOException { if (closed) { throw new IOException("Stream is closed"); } if (buffer.remaining() <= 0) { flushBuffer(); } buffer.put((byte) b); }
flushBuffer(); while ((read = rbc.read(buffer)) != -1) { if (buffer.remaining() == 0) { flushBuffer();
@Override public void write(byte[] input, int offset, int length) throws IOException { if (closed) { throw new IOException("Stream is closed"); } if (input == null) { throw new NullPointerException(); } else if ((offset < 0) || (offset > input.length) || (length < 0) || ((offset + length) > input.length) || ((offset + length) < 0)) { throw new IndexOutOfBoundsException(); } while (length > 0) { if (buffer.remaining() <= 0) { flushBuffer(); } final int toPut = Math.min(length, buffer.remaining()); buffer.put(input, offset, toPut); offset += toPut; length -= toPut; } }