Class XMLEncodingSniffer


  • public final class XMLEncodingSniffer
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XMLEncodingSniffer()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean hasUTF8BOM​(java.io.InputStream in)
      Checks if the parameter input stream has a UTF-8 byte order mark.
      private static boolean matchesMagic​(byte[] magic, byte[] buffer)  
      static java.lang.String sniffEncoding​(java.io.InputStream in)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UTF16_MAGIC

        private static final byte[][] UTF16_MAGIC
      • UCS4_MAGIC

        private static final byte[][] UCS4_MAGIC
      • UTF8_MAGIC

        private static final byte[] UTF8_MAGIC
      • EBCDIC_MAGIC

        private static final byte[] EBCDIC_MAGIC
    • Constructor Detail

      • XMLEncodingSniffer

        private XMLEncodingSniffer()
    • Method Detail

      • matchesMagic

        private static boolean matchesMagic​(byte[] magic,
                                            byte[] buffer)
      • sniffEncoding

        public static java.lang.String sniffEncoding​(java.io.InputStream in)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • hasUTF8BOM

        public static boolean hasUTF8BOM​(java.io.InputStream in)
                                  throws java.io.IOException
        Checks if the parameter input stream has a UTF-8 byte order mark.
        Parameters:
        in - an input stream
        Returns:
        true if and only if the input stream starts with a UTF-8 BOM
        Throws:
        java.io.IOException