code: public void mark(int readlimit) {
          abortIfNeeded();
          if (log.isDebugEnabled()) {
              log.debug("Input stream marked at " + bytesReadPastMark + " bytes");
          }
          if (bytesReadPastMark <= bufferSize && buffer != null) {
              /*
               * Clear buffer of already-read data to make more space. It's safe
               * to cast bytesReadPastMark to an int because it is known to be
               * less than bufferSize, which is an int.
               */
              byte[] newBuffer = new byte[this.bufferSize];
              System.arraycopy(buffer, bufferOffset, newBuffer, 0, (int)(bytesReadPastMark - bufferOffset));
              this.buffer = newBuffer;
              this.bytesReadPastMark -= bufferOffset;
              this.bufferOffset = 0;
          } else {
              // If mark is called after the buffer was already exceeded, create a new buffer.
              this.bufferOffset = 0;
              this.bytesReadPastMark = 0;
              this.buffer = new byte[this.bufferSize];
          }
      }
docs: This method can only be used while less data has been read from the input
  stream than fits into the buffer. The readLimit parameter is ignored
  entirely.