Class NullReader

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

    public class NullReader
    extends java.io.Reader
    implements java.io.Serializable
    End-of-stream-only reader.

    This reader will always return end-of-file on any read attempt.

    This class is a singleton. You cannot create a null reader, but you can obtain an instance of this class using getInstance().

    Since:
    0.9.2
    Author:
    Sebastiano Vigna
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.io.Reader

        lock
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static NullReader getInstance()
      Returns the only instance of this class.
      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
    • Method Detail

      • getInstance

        public static NullReader getInstance()
        Returns the only instance of this class.
        Returns:
        the only instance of this class.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Reader
      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
        Specified by:
        read in class java.io.Reader