Class UnicodeInputStreamReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable
    Direct Known Subclasses:
    UnicodeFileReader

    public class UnicodeInputStreamReader
    extends Reader
    A variation of InputStreamReader that is BOM-aware. It can operate in any of the following modes:
    • As a standard input stream reader that uses the default JVM charset.
    • A reader that uses a specific charset and assumes a specific signature is present in the input stream (and skips it without confirming that it's actually present and valid).
    • A reader that looks for a signature match among several candidates, and thus automatically determines the charset.
    Since:
    0.6.0
    Version:
    $Id: UnicodeInputStreamReader.java 16154 2012-07-14 16:34:05Z colin $
    Author:
    tlerios@marketcetera.com
    • Constructor Detail

      • UnicodeInputStreamReader

        public UnicodeInputStreamReader​(InputStream stream)
        Creates a new reader over the given stream that uses the default JVM charset.
        Parameters:
        stream - The stream.
      • UnicodeInputStreamReader

        public UnicodeInputStreamReader​(InputStream stream,
                                        SignatureCharset requestedSignatureCharset)
        Creates a new reader over the given stream that normally assumes the given signature is present and its associated charset should be used. However, if the charset in the given signature/charset pair is not supported by the JVM, the default JVM charset is used instead.
        Parameters:
        stream - The stream.
        requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
      • UnicodeInputStreamReader

        public UnicodeInputStreamReader​(InputStream stream,
                                        DecodingStrategy decodingStrategy)
        Creates a new reader over the given stream that normally uses the charset associated with a matching signature among those of the given decoding strategy. However, if no signature matches, or if the charset of the matching signature is not supported by the JVM, the default JVM charset is used instead.
        Parameters:
        stream - The stream.
        decodingStrategy - The decoding strategy. It may be null to use the default JVM charset.