public CharsetDetector setText(InputStream in) throws IOException {
        fInputStream = in;
        fInputStream.mark(kBufSize);
        byte[] inputBytes = 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.
        long bytesRead = -1;
        try {
            bytesRead = IOUtils.read(fInputStream, inputBytes);
            if (bytesRead >= Integer.MAX_VALUE) {
                throw new IOException("Can't have read > Integer.MAX_VALUE bytes");
            }
        } finally {
            fInputStream.reset();
        }

        if (bytesRead < 1) {
            return setText(new byte[0]);
        } else if (kBufSize > bytesRead) {
            return setText(inputBytes, (int) bytesRead);
        } else {
            return setText(inputBytes);
        }
    }
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
@stable ICU 3.4
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-text-module/src/main/java/org/apache/tika/parser/txt/CharsetDetector.java