code: @Override
      public int read() throws IOException {
          if (max >= 0 && pos >= max) {
              return -1;
          }
          int result = in.read();
          pos++;
          return result;
      }
docs: Invokes the delegate's <code>read()</code> method if
  the current position is less than the limit.
  
  @return the byte read or -1 if the end of stream or
  the limit has been reached.
  @throws java.io.IOException if an I/O error occurs