public Reader getReader(InputStream in, String declaredEncoding) {
        fDeclaredEncoding = declaredEncoding;

        try {
            setText(in);

            CharsetMatch match = detect();

            if (match == null) {
                return null;
            }

            return match.getReader();
        } catch (IOException e) {
            return null;
        }
    }
Autodetect the charset of an inputStream, and return a Java Reader
to access the converted input data.
<p>
This is a convenience method that is equivalent to
<code>this.setDeclaredEncoding(declaredEncoding).setText(in).detect().getReader();</code>
<p>
For the input stream that supplies the character data, markSupported()
must be true; the  charset detection 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.
<p>
Raise an exception if no charsets appear to match the input data.

@param in               The source of the byte data in the unknown charset.
@param declaredEncoding A declared encoding for the data, if available,
                        or null or an empty string if none is available.
@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