Class 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  
      • Fields inherited from class java.io.Reader

        lock
    • 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)  
      • Methods inherited from class java.io.Reader

        mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reader

        java.io.InputStreamReader reader
      • encoding

        java.lang.String encoding
      • MAX_BOM_LENGTH

        int MAX_BOM_LENGTH
    • 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 class java.io.Reader
        Throws:
        java.io.IOException
      • close

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