Class UnsynchronizedReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable
    Direct Known Subclasses:
    UnsynchronizedBufferedReader

    public abstract class UnsynchronizedReader
    extends java.io.Reader
    A Reader without any of the superclass' synchronization.
    Since:
    2.17.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean closed
      Whether close() completed successfully.
      private static int MAX_SKIP_BUFFER_SIZE
      The maximum skip-buffer size.
      private char[] skipBuffer
      The skip buffer, defaults to null until allocated in skip(long).
      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      UnsynchronizedReader()
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void checkOpen()
      Checks if this instance is closed and throws an IOException if so.
      void close()  
      boolean isClosed()
      Tests whether this instance is closed; if close() completed successfully.
      void setClosed​(boolean closed)
      Sets whether this instance is closed.
      long skip​(long n)
      Skips characters by reading from this instance.
      • Methods inherited from class java.io.Reader

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

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

      • MAX_SKIP_BUFFER_SIZE

        private static final int MAX_SKIP_BUFFER_SIZE
        The maximum skip-buffer size.
        See Also:
        Constant Field Values
      • closed

        private boolean closed
        Whether close() completed successfully.
      • skipBuffer

        private char[] skipBuffer
        The skip buffer, defaults to null until allocated in skip(long).
    • Constructor Detail

      • UnsynchronizedReader

        public UnsynchronizedReader()
        Constructs a new instance.
    • Method Detail

      • checkOpen

        void checkOpen()
                throws java.io.IOException
        Checks if this instance is closed and throws an IOException if so.
        Throws:
        java.io.IOException - if this instance is closed.
      • 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
      • isClosed

        public boolean isClosed()
        Tests whether this instance is closed; if close() completed successfully.
        Returns:
        whether this instance is closed.
      • setClosed

        public void setClosed​(boolean closed)
        Sets whether this instance is closed.
        Parameters:
        closed - whether this instance is closed.
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Skips characters by reading from this instance. This method will block until:
        • some characters are available,
        • an I/O error occurs, or
        • the end of the stream is reached.
        Overrides:
        skip in class java.io.Reader
        Parameters:
        n - The number of characters to skip.
        Returns:
        The number of characters actually skipped.
        Throws:
        java.lang.IllegalArgumentException - If n is negative.
        java.io.IOException - If an I/O error occurs.