Class StringIO

  • All Implemented Interfaces:
    IOInterface

    public class StringIO
    extends Object
    implements IOInterface
    An IO class backed by strings. This is used in e.g. web apps as a dummy where the actual control flow is managed by something else. Call flush() between calls to reset everything.

    Created by Jeff Gaynor
    on 8/15/22 at 2:14 PM

    • Constructor Detail

      • StringIO

        public StringIO​(String input)
    • Method Detail

      • getInput

        public String getInput()
      • setInput

        public void setInput​(String input)
      • print

        public void print​(Object x)
        Description copied from interface: IOInterface
        Print the string representation of an object, without a carriage return.
        Specified by:
        print in interface IOInterface
      • println

        public void println​(Object x)
        Description copied from interface: IOInterface
        Print the string representation of an object with a carriage return.
        Specified by:
        println in interface IOInterface
      • flush

        public void flush()
        Description copied from interface: IOInterface
        Flush anything waiting to be printed. Normally this is done with the print methods.
        Specified by:
        flush in interface IOInterface
      • clearQueue

        public void clearQueue()
        Description copied from interface: IOInterface
        Some implementations will have a queue e.g. if the user paste text from the clipboard). The IOInterface.readline(String) methods will queue these up and return them in sequence -- this is done silently. If for some reason you need only a single line and want to discard anything else, invoke this.
        Specified by:
        clearQueue in interface IOInterface
      • isQueueEmpty

        public boolean isQueueEmpty()
        Description copied from interface: IOInterface
        Check if the queue is empty.
        Specified by:
        isQueueEmpty in interface IOInterface
        Returns:
      • setBufferingOn

        public void setBufferingOn​(boolean bufferOn)
        Description copied from interface: IOInterface
        If this object supports buffering of commands, this will toggle it. Buffering means that every result of IOInterface.readline(String) will be stored and up down arrows will cycle through them.
        Specified by:
        setBufferingOn in interface IOInterface
      • isBufferingOn

        public boolean isBufferingOn()
        Description copied from interface: IOInterface
        return current state of buffering.
        Specified by:
        isBufferingOn in interface IOInterface
        Returns: