Class BOMAwareInputStream

    • Constructor Detail

      • BOMAwareInputStream

        public BOMAwareInputStream​(InputStream input,
                                   String defaultEncoding)
        Creates a new BOMAwareInputStream object for a given InputStream and a given default encoding.
        Parameters:
        input - The input stream to use.
        defaultEncoding - The default encoding to use if none can be auto-detected.
    • Method Detail

      • detectEncoding

        public String detectEncoding()
                              throws IOException
        Tries to detect the presence of a Byte-Order-Mark.
        Returns:
        The encoding guessed after the try. If nothing has been found, the default encoding is returned.
        Throws:
        IOException - if an I/O error occurs.
      • getDetectedEncoding

        public String getDetectedEncoding()
        Gets the encoding that was guessed. It can be the default encoding.
        Returns:
        the guessed encoding.
      • autoDtected

        public boolean autoDtected()
        Indicates if the guessed encoding was auto-detected. If not it is the default encoding that was provided.
        Returns:
        True if the guessed encoding was auto-detected, false if not.
      • getBOMSize

        public int getBOMSize()
        Gets the number of bytes used by the Byte-Order-mark in this document.
        Returns:
        The byte size of the BOM in this document.
      • hasUTF8BOM

        public boolean hasUTF8BOM()
        Indicates if the guessed encoding is UTF-8 and this file has a BOM.
        Returns:
        True if the guessed encoding is UTF-8 and this file has a BOM, false otherwise.