org.apache.commons.io.input

Class ClosedReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable

    public class ClosedReader
    extends Reader
    Closed reader. This reader returns EOF to all attempts to read something from it.

    Typically uses of this class include testing for corner cases in methods that accept readers and acting as a sentinel value instead of a null reader.

    Since:
    2.7
    • Field Detail

      • CLOSED_READER

        public static final ClosedReader CLOSED_READER
        A singleton.
    • Constructor Detail

      • ClosedReader

        public ClosedReader()
    • Method Detail

      • read

        public int read(char[] cbuf,
                        int off,
                        int len)
        Returns -1 to indicate that the stream is closed.
        Specified by:
        read in class  Reader
        Parameters:
        cbuf - ignored
        off - ignored
        len - ignored
        Returns:
        always -1

Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.