Class EncodingCheck


  • public class EncodingCheck
    extends Object

    Library to check if and encoding is respected.

    Author:
    Fugerit
    • Field Detail

      • READ_BUFFER_SIZE

        public static final int READ_BUFFER_SIZE
        Buffer size for reading the input
        See Also:
        Constant Field Values
    • Method Detail

      • checkEncoding

        public static boolean checkEncoding​(InputStream is,
                                            String encoding)
                                     throws IOException

        Check encoding from an input stream. Reading is buffered.

        Parameters:
        is - the source stream
        encoding - encoding to check
        Returns:
        true if all bytes belong to give encoding, false otherwise.
        Throws:
        IOException - in case issues arise
      • checkEncoding

        public static boolean checkEncoding​(byte[] bytes,
                                            String encoding)

        Check if every byte in an array belong to a given encoding.

        Parameters:
        bytes - the source byte array
        encoding - encoding to check
        Returns:
        true if all bytes belong to give encoding, false otherwise.