Package com.ibm.icu.dev.test.perf
Class PerfTest.BOMFreeReader
java.lang.Object
java.io.Reader
com.ibm.icu.dev.test.perf.PerfTest.BOMFreeReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
- Enclosing class:
PerfTest
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) String(package private) int(package private) InputStreamReader -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new reader, skipping a BOM associated with the given encoding.BOMFreeReader(InputStream in, String encoding) Creates a new reader, skipping a BOM associated with the given encoding. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()private intdetectBOMLength(byte[] start) Determines the length of a BOM in the beginning of start.intread(char[] cbuf, int off, int len) Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
Field Details
-
reader
InputStreamReader reader -
encoding
String encoding -
MAX_BOM_LENGTH
int MAX_BOM_LENGTH
-
-
Constructor Details
-
BOMFreeReader
Creates a new reader, skipping a BOM associated with the given encoding. Equivalent to BOMFreeReader(in, null).- Parameters:
in- The input stream.- Throws:
IOException- Thrown if reading for a BOM causes an IOException.
-
BOMFreeReader
Creates a new reader, skipping a BOM associated with the given encoding. If encoding is null, attempts to detect the encoding by the BOM.- Parameters:
in- The input stream.encoding- The encoding to use. Can be null.- Throws:
IOException- Thrown if reading for a BOM causes an IOException.
-
-
Method Details
-
detectBOMLength
private int detectBOMLength(byte[] start) Determines the length of a BOM in the beginning of start. Assumes start is at least a length 5 array. If encoding is null, the check will not be encoding specific and it will set the encoding of this BOMFreeReader.- Parameters:
start- The starting bytes.encoding- The encoding. Can be null.- Returns:
- The length of a detected BOM.
-
read
- Specified by:
readin classReader- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-