code: public int dataAvailable() {
          if (readBuffer.position() < fillBuffer.position()) {
              return readBuffer.remaining();
          } else if (readBuffer.position() > fillBuffer.position()) {
              return capacity - fillBuffer.remaining();
          } else {
              if (readBuffer.hasRemaining()) {
                  return readBuffer.remaining() + fillBuffer.position();
              } else {
                  return 0;
              }
          }
      }
docs: Gets the number of bytes that can be read.
  
  @return Integer indicating the number of bytes that can be read.