public int read() throws IOException { if (pos >= limit) { limit = readInput(buf, 0, buf.length); pos = 0; } return buf[pos++] & 0xFF; }
public void readFully(byte[] bytes, int start, int len) throws IOException { int buffered = limit - pos; if (len > buffered) { // buffer is insufficient System.arraycopy(buf, pos, bytes, start, buffered); // consume buffer start += buffered; len -= buffered; pos += buffered; if (len > buf.length) { // bigger than buffer do { int read = readInput(bytes, start, len); // read directly into result len -= read; start += read; } while (len > 0); return; } limit = readInput(buf, 0, buf.length); // refill buffer pos = 0; } System.arraycopy(buf, pos, bytes, start, len); // copy from buffer pos += len; }
public int read() throws IOException { if (pos >= limit) { limit = readInput(buf, 0, buf.length); pos = 0; } return buf[pos++] & 0xFF; }
public void readFully(byte[] bytes, int start, int len) throws IOException { int buffered = limit - pos; if (len > buffered) { // buffer is insufficient System.arraycopy(buf, pos, bytes, start, buffered); // consume buffer start += buffered; len -= buffered; pos += buffered; if (len > buf.length) { // bigger than buffer do { int read = readInput(bytes, start, len); // read directly into result len -= read; start += read; } while (len > 0); return; } limit = readInput(buf, 0, buf.length); // refill buffer pos = 0; } System.arraycopy(buf, pos, bytes, start, len); // copy from buffer pos += len; }