Class CharacterDevice

java.lang.Object
de.audioattack.io.CharacterDevice
All Implemented Interfaces:
Console, Flushable

public class CharacterDevice extends Object implements Console
Console which is based on provided readers and writers.
  • Method Details

    • reader

      public Reader reader()
      Gets a Reader associated with the console. Invoking close() on this object will not close the underlying stream.
      Specified by:
      reader in interface Console
      Returns:
      the reader
      See Also:
    • writer

      public PrintWriter writer()
      Gets a PrintWriter associated with the console. Invoking close() on this object will not close the underlying stream.
      Specified by:
      writer in interface Console
      Returns:
      the writer
      See Also:
    • format

      public Console format(String fmt, Object... args)
      Writes formatted String.
      Specified by:
      format in interface Console
      Parameters:
      fmt - format String
      args - arguments to replace format specifiers in format String
      Returns:
      this console
      See Also:
    • printf

      public Console printf(String fmt, Object... args)
      Convenience method which writes formatted String.
      Specified by:
      printf in interface Console
      Parameters:
      fmt - format String
      args - arguments to replace format specifiers in format String
      Returns:
      this console
      See Also:
    • readLine

      public String readLine(String fmt, Object... args)
      Writes formatted prompt and reads single line.
      Specified by:
      readLine in interface Console
      Parameters:
      fmt - format String
      args - arguments to replace format specifiers in format String
      Returns:
      the line
      See Also:
    • readLine

      public String readLine()
      Reads single line.
      Specified by:
      readLine in interface Console
      Returns:
      the line
      See Also:
    • readPassword

      public char[] readPassword(String fmt, Object... args)
      Writes formatted prompt and reads password. Hidden input should be preferred if possible. Implementations which cannot hide input should display a warning that entered text will be visible.
      Specified by:
      readPassword in interface Console
      Parameters:
      fmt - format String
      args - arguments to replace format specifiers in format String
      Returns:
      the password
      See Also:
    • readPassword

      public char[] readPassword()
      Reads password. Hidden input should be preferred if possible. Implementations which cannot hide input should display a warning that entered text will be visible.
      Specified by:
      readPassword in interface Console
      Returns:
      the password
      See Also:
    • flush

      public void flush()
      Specified by:
      flush in interface Flushable