@Override public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // if more bytes wanted than available return all available int bytesAvailable = buffer.length - bufferPointer; if (len > bytesAvailable) { len = bytesAvailable; } System.arraycopy(buffer, bufferPointer, b, off, len); bufferPointer += len; return len; }
public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // if more bytes wanted than available return all available int bytesAvailable = buffer.length - bufferPointer; if (len > bytesAvailable) { len = bytesAvailable; } System.arraycopy(buffer, bufferPointer, b, off, len); bufferPointer += len; return len; }
public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // if more bytes wanted than available return all available int bytesAvailable = buffer.length - bufferPointer; if (len > bytesAvailable) { len = bytesAvailable; } System.arraycopy(buffer, bufferPointer, b, off, len); bufferPointer += len; return len; }
public synchronized int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // if more bytes wanted than available return all available int bytesAvailable = buffer.length - bufferPointer; if (len > bytesAvailable) { len = bytesAvailable; } System.arraycopy(buffer, bufferPointer, b, off, len); bufferPointer += len; return len; }
public synchronized int read() throws IOException { checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // return byte and increment buffer pointer return (int) buffer[bufferPointer++]; }
public synchronized int read() throws IOException { checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // return byte and increment buffer pointer return ((int) buffer[bufferPointer++]) & 0xff; }
public synchronized int read() throws IOException { checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // return byte and increment buffer pointer return (int) buffer[bufferPointer++]; }
@Override public synchronized int read() throws IOException { checkClosed(); // if nothing read yet or whole buffer has been read fill buffer if (bufferPointer == -1 || bufferPointer >= buffer.length) { // if no data available and stream was closed return -1 if (!loadBuffer()) { return -1; } } // return byte and increment buffer pointer return buffer[bufferPointer++] & 0xff; }