Class Utf8StreamReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    public class Utf8StreamReader
    extends java.io.Reader
    Similar to java native InputStreamReader, but locked to utf-8, and explicitly with no buffering whatsoever. It will only read one byte at a time until it has a valid unicode char.

    In order to make this reader more efficient, rather wrap the input stream in a BufferedInputStream, which can pass on any buffered bytes to later uses. E.g.:

         Reader reader = new Utf8StreamReader(new BufferedInputStream(in));
     
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      Utf8StreamReader​(java.io.InputStream in)  
      Utf8StreamReader​(java.io.InputStream in, boolean strict)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      int read​(char[] char_buffer, int off, int len)  
      boolean ready()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from class java.io.Reader

        mark, markSupported, read, read, read, reset, skip, transferTo
    • Constructor Detail

      • Utf8StreamReader

        public Utf8StreamReader​(java.io.InputStream in)
      • Utf8StreamReader

        public Utf8StreamReader​(java.io.InputStream in,
                                boolean strict)
    • Method Detail

      • read

        public int read​(@Nonnull
                        char[] char_buffer,
                        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
      • ready

        public boolean ready()
                      throws java.io.IOException
        Overrides:
        ready in class java.io.Reader
        Throws:
        java.io.IOException