Skip navigation links
oracle.i18n.text
Class UTF8ValidationFilter
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
oracle.i18n.text.UTF8ValidationFilter
- All Implemented Interfaces:
- Closeable
-
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
Method Summary |
int |
read()
Reads one byte. |
int |
read(byte[] b, int off, int len)
Reads the byte array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
read
public int read()
throws UTFDataFormatException,
IOException
- Reads one byte.
-
- Overrides:
read
in class BufferedInputStream
-
- Returns:
- a byte from the input stream
- Throws:
UTFDataFormatException
- if any illegal UTF-8 sequence is found
IOException
- if any other I/O error occurs
read
public int read(byte[] b,
int off,
int len)
throws UTFDataFormatException,
IOException
- Reads the byte array.
-
- Overrides:
read
in class BufferedInputStream
-
- Parameters:
b
- buffer
off
- offset
len
- length
- Returns:
- the number of bytes copied
- Throws:
UTFDataFormatException
- if any illegal UTF-8 sequence is found
IOException
- if any other I/O error occurs
Skip navigation links
Copyright © 2003, 2007, Oracle. All rights reserved.