If the buffer has no more bytes to be read, and there are bytes available in the file, load more bytes.

@throws IOException
433947
private void loadBytesAsNeeded() throws IOException {
        if (available() <= 0) {
            _isEof = true;
        }

        while ((!_isEof) && (bytesLeftInBuffer() <= 0)) {
            _currentBufferPosition = 0;
            NfsReadResponse response = _file.read(_offset, _bytes.length, _bytes, _currentBufferPosition);
            _bytesInBuffer = response.getBytesRead();
            _offset += _bytesInBuffer;
            _isEof = response.isEof();
        }
    }
724064
private void buffer() throws IOException {
        int remaining = buffer.length;
        while (remaining > 0) {
            int r = input.read(buffer, buffer.length - remaining, remaining);
            if (r <= 0) {
                // Not enough information to fill the buffer
                offset = 0;
                maxOffset = buffer.length - remaining;
                return;
            }
            remaining -= r;
        }
        maxOffset = buffer.length;
        offset = 0;
    }
347344
private void fill() throws IOException {
    int i = in.read(buf, 0, buf.length);
    if (i > 0) {
      pos = 0;
      count = i;
    }
  }
37684
private void fill() throws IOException {
    int n;
    previousBufferSize += nChars;
    do {
      n = in.read(cb, 0, cb.length);
    } while (n == 0);
    if (n > 0) {
      nChars = n;
      nextChar = 0;
    }
  }
145359
private void fill() throws IOException {
        byte[] buffer = getBufIfOpen();
        if (markpos < 0)
            pos = 0;            /* no mark: throw away the buffer */
        else if (pos >= buffer.length)  /* no room left in buffer */
            if (markpos > 0) {  /* can throw away early part of the buffer */
                int sz = pos - markpos;
                System.arraycopy(buffer, markpos, buffer, 0, sz);
                pos = sz;
                markpos = 0;
            } else if (buffer.length >= marklimit) {
                markpos = -1;   /* buffer got too big, invalidate mark */
                pos = 0;        /* drop buffer contents */
            } else if (buffer.length >= MAX_BUFFER_SIZE) {
                throw new OutOfMemoryError("Required array size too large");
            } else {            /* grow buffer */
                int nsz = (pos <= MAX_BUFFER_SIZE - pos) ?
                        pos * 2 : MAX_BUFFER_SIZE;
                if (nsz > marklimit)
                    nsz = marklimit;
                byte nbuf[] = new byte[nsz];
                System.arraycopy(buffer, 0, nbuf, 0, pos);
                if (!compareAndSetBuf(buffer, nbuf)) {
                    // Can't replace buf if there was an async close.
                    // Note: This would need to be changed if fill()
                    // is ever made accessible to multiple threads.
                    // But for now, the only way CAS can fail is via close.
                    // assert buf == null;
                    throw new IOException("Stream closed");
                }
                buffer = nbuf;
            }
        count = pos;
        int n = getInIfOpen().read(buffer, pos, buffer.length - pos);
        if (n > 0)
            count = n + pos;
    }
504718
private void fillPacket() throws IOException
    {
        if (_closed)
            return;

        if (_gotFirst||_in.available()==0)
            _getBodyChunk.write(_out);
        _gotFirst=true;

        // read packet
        if (!_packet.read(_in))
            throw new IOException("EOF");

        if (_packet.unconsumedData()<=0)
            _closed=true;
        else if (_packet.getInt()>_packet.getBufferSize())
            throw new IOException("AJP Protocol error");
    }
183495
private int fillBuffer() throws IOException {
    int n = super.read(buffer, 0, BUF_SIZE);
    if (n >= 0) {
      real_pos += n;
      buf_end = n;
      buf_pos = 0;
    }
    return n;
  }
232970
protected void flushBuffer() throws IOException {
		if (capacity == 0) {
			ostream.write(buffer);
			capacity = BITS_IN_BYTE;
			buffer = 0;
			len++;
		}
	}
1299284
public void ensureCapacity(int n)
        throws IOException
    {
        // Do we have space?
        if (n>capacity())
        {
            // Make a bigger buffer if we are allowed.
            if (_fixed)
                throw new IllegalStateException("Fixed");
                
            int new_size = ((n+_preReserve+_postReserve+4095)/4096)*4096;
            
            byte[] old = _buf;
            _buf = new byte[new_size];
            if (_pos>_start)
                System.arraycopy(old,_start,_buf,_start,_pos-_start);
            if (!_resized)
                ByteArrayPool.returnByteArray(old);
                
            _end=_buf.length-_postReserve;
            _resized=true;
        }
    }
646035
public int read(byte[] buf, int off, int len) throws IOException {
    while (true) {
      lockR.lock();
      try {
        int available = availableCount.get();
        if (available > 0) {
          // as long as there is available data
          // serve it even if closed
          final int lenToRead = Math.min(available, len);
          final int lenForward = Math.min(lenToRead, length - readCursor);
          final int lenRemaining = lenToRead - lenForward;
          
          // after readCursor
          if (lenForward > 0) {
            System.arraycopy(bytes, readCursor, buf, off, lenForward);
            incReadCursor(lenForward);
          }
          
          // before readCursor
          if (lenRemaining > 0) {
            System.arraycopy(bytes, 0, buf, off + lenForward, lenRemaining);
            incReadCursor(lenRemaining);
          } 
          availableCount.addAndGet(-1 * lenToRead);
          totalRead += lenToRead;
          return lenToRead;
        } else if (nonBlockingRead) {
          // we do not serve any bytes
          return 0;
        } else if (closed) {
          // when no bytes are left and buffer is closed
          // return -1
          return -1;
        }
      } finally {
        lockR.unlock();
      }
      sleep(1);
    }
  }
566661
public int read(byte []buffer, int offset, int length)
    throws IOException
  {
    return _file.read(buffer, offset, length);
  }
853709
public synchronized void load2() throws IOException {
        COL result = create();

        if (exists()) {
            try (LinesStream stream = linesStream()) {
                for (String line : stream) {
                    if (line.startsWith("#")) continue;   // comment
                    T r = parse(line);
                    if (r != null)
                        result.add(r);
                }
            }
        }

        parsed = readOnly(result);
    }
829766
public void readAll(InputStream in) throws IOException {
    int read = 0;
    do {
      grow(length);
      read = data.setBytes(length, in, data.length() - length);
      if (read > 0) {
        length += read;
      }
    } while (in.available() > 0);
  }
1049747
public void reader() throws IOException {
    // [START reader]
    try (ReadChannel reader = blob.reader()) {
      ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
      while (reader.read(bytes) > 0) {
        bytes.flip();
        // do something with bytes
        bytes.clear();
      }
    }
    // [END reader]
  }
200900
public byte[] readRemainingBytes() throws IOException {
    if (this.available() > 0) {
      byte[] b = new byte[this.available()];
      if (read(b) >= 0) {
        return b;
      } else {
        throw new IOException("returned negative number of remaining bytes");
      }
    } else {
      throw new IOException("no more bytes");
    }
  }
1260636
private void writeBuffer() throws IOException {
    for (int pos = 0; pos < currentBufferSize; pos++) {
      if (isByte[pos]) {
        aFile.write((byte) buffer[pos]);
      } else {
        aFile.write(buffer[pos]);
      }
    }
  }
246380
public void load(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder out = new StringBuilder();
        String line;

        while ((line = reader.readLine()) != null) {
            out.append(line);
            out.append(System.lineSeparator());
        }

        setScriptText(out.toString());
    }