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:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
- Enclosing class:
- PerfTest
public static class PerfTest.BOMFreeReader extends java.io.Reader
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
encoding
(package private) int
MAX_BOM_LENGTH
(package private) java.io.InputStreamReader
reader
-
Constructor Summary
Constructors Constructor Description BOMFreeReader(java.io.InputStream in)
Creates a new reader, skipping a BOM associated with the given encoding.BOMFreeReader(java.io.InputStream in, java.lang.String encoding)
Creates a new reader, skipping a BOM associated with the given encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private int
detectBOMLength(byte[] start)
Determines the length of a BOM in the beginning of start.int
read(char[] cbuf, int off, int len)
-
-
-
Constructor Detail
-
BOMFreeReader
public BOMFreeReader(java.io.InputStream in) throws java.io.IOException
Creates a new reader, skipping a BOM associated with the given encoding. Equivalent to BOMFreeReader(in, null).- Parameters:
in
- The input stream.- Throws:
java.io.IOException
- Thrown if reading for a BOM causes an IOException.
-
BOMFreeReader
public BOMFreeReader(java.io.InputStream in, java.lang.String encoding) throws java.io.IOException
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:
java.io.IOException
- Thrown if reading for a BOM causes an IOException.
-
-
Method Detail
-
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
public int read(char[] cbuf, int off, int len) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
-