code: public void readFully(byte[] buffer, int offset, int count) throws IOException
      {
          if (buffer == null) {
              throw new NullPointerException();
          }
          // avoid int overflow
          if (offset < 0 || offset > buffer.length || count < 0
                  || count > buffer.length - offset) {
              throw new IndexOutOfBoundsException();
          }
          while (count > 0) {
              int result = read(buffer, offset, count);
              if (result < 0) {
                  throw new EOFException();
              }
              offset += result;
              count -= result;
          }
      }
docs: Read bytes from this file into {@code buffer} starting at offset {@code
  offset}. This method blocks until {@code count} number of bytes have been
  read.
  
  @param buffer
  the buffer to read bytes into.
  @param offset
  the initial position in {@code buffer} to store the bytes read
  from this file.
  @param count
  the maximum number of bytes to store in {@code buffer}.
  @throws EOFException
  if the end of this file is detected.
  @throws IndexOutOfBoundsException
  if {@code offset < 0} or {@code count < 0}, or if {@code
  offset + count} is greater than the length of {@code buffer}.
  @throws IOException
  if this file is closed or another I/O error occurs.
  @throws NullPointerException
  if {@code buffer} is {@code null}.