private void readFully(byte[] buffer) throws IOException {
    int bytesToRead = buffer.length;
    int bytesSoFar = 0;
    while (bytesSoFar < buffer.length) {
      int bytesRead = inputStream.read(buffer, bytesSoFar, bytesToRead);
      if (bytesRead <= 0) {
        throw new EOFException();
      }
      bytesSoFar += bytesRead;
      bytesToRead -= bytesRead;
    }
  }
private void readFully(byte[] buffer)