Flushable
, ProgramConsole
public final class ConsoleProgramConsole extends Object implements ProgramConsole
Console
to a ProgramConsole
.
This class is conditionally thread-safe. Since it wraps a Console
,
it has the same possibility for some calls to block in multithreaded
scenarios as noted in the Console
class documentation.
Constructor | Description |
---|---|
ConsoleProgramConsole(Console adaptee) |
Constructs an instance with the specified console.
|
Modifier and Type | Method | Description |
---|---|---|
void |
flush() |
Ensures that any buffered output is written out.
|
ConsoleProgramConsole |
format(String fmt,
Object... args) |
Prints the message.
|
ConsoleProgramConsole |
printf(String format,
Object... args) |
Prints the message.
|
Reader |
reader() |
Returns the underlying reader of this console.
|
String |
readLine() |
Reads a line of input.
|
String |
readLine(String fmt,
Object... args) |
Prints a prompt, and reads a line of input.
|
char[] |
readPassword() |
Reads a password with echoing turned off.
|
char[] |
readPassword(String fmt,
Object... args) |
Prints a prompt, and reads a password with echoing turned off.
|
static ConsoleProgramConsole |
systemInstance() |
Returns the system
ConsoleProgramConsole instance for the system
Console . |
PrintWriter |
writer() |
Returns the underlying writer of this console.
|
public ConsoleProgramConsole(Console adaptee)
adaptee
- the Console
to adapt to this interfaceNullPointerException
- if adaptee
is null
public PrintWriter writer()
ProgramConsole
This behaves exactly like Console.writer()
.
writer
in interface ProgramConsole
public Reader reader()
ProgramConsole
This behaves exactly like Console.reader()
.
reader
in interface ProgramConsole
public ConsoleProgramConsole format(String fmt, Object... args)
ProgramConsole
This behaves exactly like
Console.format(String, Object...)
.
format
in interface ProgramConsole
fmt
- the format string as defined by Formatter
args
- the format string argumentspublic ConsoleProgramConsole printf(String format, Object... args)
ProgramConsole
This behaves exactly like
Console.printf(String, Object...)
.
printf
in interface ProgramConsole
format
- the format string as defined by Formatter
args
- the format string argumentspublic String readLine(String fmt, Object... args)
ProgramConsole
This behaves exactly like
Console.readLine(String, Object...)
.
readLine
in interface ProgramConsole
fmt
- the prompt format string as defined by
Formatter
args
- the format string argumentsnull
if the end of the stream is reachedpublic String readLine()
ProgramConsole
This behaves exactly like Console.readLine()
.
readLine
in interface ProgramConsole
null
if the end of the stream is reachedpublic char[] readPassword(String fmt, Object... args)
ProgramConsole
This behaves exactly like
Console.readPassword(String, Object...)
.
readPassword
in interface ProgramConsole
fmt
- the prompt format string as defined by
Formatter
args
- the format string argumentschar
array, not including the line
terminator, or null
if the end of the stream is reachedpublic char[] readPassword()
ProgramConsole
This behaves exactly like Console.readPassword()
.
readPassword
in interface ProgramConsole
char
array, not including the line
terminator, or null
if the end of the stream is reachedpublic void flush()
ProgramConsole
This behaves exactly like Console.flush()
.
flush
in interface Flushable
flush
in interface ProgramConsole
public static ConsoleProgramConsole systemInstance()
ConsoleProgramConsole
instance for the system
Console
.null
if there is no system
Console