Class UTF8ValidationFilter

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class UTF8ValidationFilter
    extends BufferedInputStream
    The UTF8ValidationFilter class is used to check the illegal UTF-8 byte sequence to replace with the replacement character U+FFFD or raise an exception.

    The validation occurs transparently for the users. The output has the same contents as the input if an invalid UTF-8 sequence is not found. If an invalid UTF-8 sequence is found and UTF8ValidationFilter.ValidationBehavior.REPLACE is specified as the conversion behavior, the output will include U+FFFD, or 0xef, 0xbf, 0xbd in UTF-8 encoding where the problem occurs. By default, the illegal UTF-8 sequence is reported by the exception UTFDataFormatException.

    Since:
    10.2
    • Constructor Detail

      • UTF8ValidationFilter

        public UTF8ValidationFilter​(InputStream in)
        Constructs the object with the InputStream object.
        Parameters:
        in - the InputStream object
      • UTF8ValidationFilter

        public UTF8ValidationFilter​(InputStream in,
                                    int size)
        Constructs the object with the InputStream object with the buffer size.
        Parameters:
        in - the InputStream object
        size - the buffer size
      • UTF8ValidationFilter

        public UTF8ValidationFilter​(InputStream in,
                                    int size,
                                    UTF8ValidationFilter.ValidationBehavior action)
        Constructs the object with the InputStream object with the buffer size and the validation behavior.
        Parameters:
        in - the InputStream object
        size - the buffer size
        action - specifies the error action to be either REPLACE or REPORT