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

public static class PerfTest.BOMFreeReader extends Reader
  • Field Details

  • Constructor Details

    • BOMFreeReader

      public BOMFreeReader(InputStream in) throws IOException
      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

      public BOMFreeReader(InputStream in, String encoding) throws 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:
      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

      public int read(char[] cbuf, int off, int len) throws IOException
      Specified by:
      read in class Reader
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
      Throws:
      IOException