code: public CharsetDetector setText(InputStream in) throws IOException {
          fInputStream = in;
          fInputStream.mark(kBufSize);
          fRawInput = new byte[kBufSize];   // Always make a new buffer because the
                                            //   previous one may have come from the caller,
                                            //   in which case we can't touch it.
          fRawLength = 0;
          int remainingLength = kBufSize;
          while (remainingLength > 0 ) {
              // read() may give data in smallish chunks, esp. for remote sources.  Hence, this loop.
              int  bytesRead = fInputStream.read(fRawInput, fRawLength, remainingLength);
              if (bytesRead <= 0) {
                   break;
              }
              fRawLength += bytesRead;
              remainingLength -= bytesRead;
          }
          fInputStream.reset();
          
          return this;
      }
docs: Set the input text (byte) data whose charset is to be detected.
  <p>
  The input stream that supplies the character data must have markSupported()
  == true; the charset detection process will read a small amount of data,
  then return the stream to its original position via
  the InputStream.reset() operation.  The exact amount that will
  be read depends on the characteristics of the data itself.
  
  @param in the input text of unknown encoding
  
  @return This CharsetDetector