public interface TextInterfaceDevice extends PasswordPrompter, Flushable, OutputDevice
ConsoleInterfaceDevice.Console and Runtime because the default and intended implementation wraps the
methods of those classes.| Modifier and Type | Field and Description |
|---|---|
static TextInterfaceDevice |
CONSOLE |
| Modifier and Type | Method and Description |
|---|---|
PrintStream |
err()
Gets the standard error stream.
|
void |
exit()
Terminates the currently running application normally (with a status code of zero).
|
void |
exit(int exitCode)
Terminates the currently running application.
|
TextInterfaceDevice |
format(String format,
Object... arguments)
Writes a formatted string to this device's output stream using the specified format string and arguments.
|
Reader |
getReader()
Retrieves the unique Reader object associated with this interface device.
|
PrintWriter |
getWriter()
Retrieves the unique PrintWriter object associated with this interface device.
|
InputStream |
in()
Gets the standard input stream.
|
PrintStream |
out()
Gets the standard output stream.
|
void |
printErr(char c)
Prints a
char to standard-err. |
void |
printErr(Object o)
Prints an
Object to standard-out. |
void |
printErr(String s)
Prints a
String to standard-err. |
void |
printErrLn()
Terminates the current standard-err line by writing the line separator string.
|
void |
printErrLn(char c)
Prints a
char to standard-err, then terminates the current line by writing the line separator string. |
void |
printErrLn(Object o)
Prints an
Object to standard-err, then terminates the current line by writing the line separator string. |
void |
printErrLn(String s)
Prints a
String to standard-err, then terminates the current line by writing the line separator string. |
TextInterfaceDevice |
printf(String format,
Object... arguments)
A convenience method to write a formatted string to this device's output stream using the specified format
string and arguments.
|
void |
printOut(char c)
Prints a
char to standard-out. |
void |
printOut(Object o)
Prints an
Object to standard-out. |
void |
printOut(String s)
Prints a
String to standard-out. |
void |
printOutLn()
Terminates the current standard-out line by writing the line separator string.
|
void |
printOutLn(char c)
Prints a
char to standard-out, then terminates the current line by writing the line separator string. |
void |
printOutLn(Object o)
Prints an
Object to standard-out, then terminates the current line by writing the line separator string. |
void |
printOutLn(String s)
Prints a
String to standard-out, then terminates the current line by writing the line separator string. |
String |
readLine()
Reads a single line of text from the device.
|
String |
readLine(String format,
Object... arguments)
Provides a formatted prompt, then reads a single line of text from the device.
|
char[] |
readPassword()
Reads a password or passphrase from the device with echoing disabled.
|
char[] |
readPassword(String format,
Object... arguments)
Provides a formatted prompt, then reads a password or passphrase from the device with echoing disabled.
|
void |
registerShutdownHook(Thread hook)
Registers a new application shutdown hook.
|
boolean |
unregisterShutdownHook(Thread hook)
De-registers a previously-registered application shutdown hook.
|
passwordsMatch, promptForValidPassword, promptForValidPasswordoutputErrorMessage, outputMessagestatic final TextInterfaceDevice CONSOLE
void registerShutdownHook(Thread hook) throws IllegalArgumentException, IllegalStateException, SecurityException
Runtime.addShutdownHook(Thread).hook - An initialized but unstarted Thread objectIllegalArgumentException - if the specified hook has already been registered, or if it can be determined that the hook is already running or has already been run.IllegalStateException - if the application is already in the process of shutting down.SecurityException - if registering shutdown hooks is forbidden.boolean unregisterShutdownHook(Thread hook) throws IllegalStateException, SecurityException
hook - The hook to removetrue if the specified hook had previously been registered and was successfully de-registered, false otherwiseIllegalStateException - if the virtual machine is already in the process of shutting down.SecurityException - if registering shutdown hooks is forbidden.void exit()
void exit(int exitCode)
exitCode - The exit status to exit withTextInterfaceDevice format(String format, Object... arguments) throws IllegalFormatException
format - A format string as described in #syntaxarguments - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.IllegalFormatException - - if a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.TextInterfaceDevice printf(String format, Object... arguments) throws IllegalFormatException, IOError
device.printf(format, args) behaves in exactly the same way as
the invocation of device.format(format, args).format - A format string as described in #syntaxarguments - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.IllegalFormatException - if a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.IOError - if an I/O error occurs.String readLine() throws IOError
null if an end of stream has been reached.IOError - if an I/O error occurs.String readLine(String format, Object... arguments) throws IllegalFormatException, IOError
format - A format string as described in #syntaxarguments - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.null if an end of stream has been reached.IllegalFormatException - if a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.IOError - if an I/O error occurs.char[] readPassword()
throws IOError
readPassword in interface PasswordPrompternull if an end of stream has been reached.IOError - if an I/O error occurs.char[] readPassword(String format, Object... arguments) throws IllegalFormatException, IOError
readPassword in interface PasswordPrompterformat - A format string as described in #syntaxarguments - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.null if an end of stream has been reached.IllegalFormatException - if a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.IOError - if an I/O error occurs.void printOut(char c)
throws IOError
char to standard-out.c - The char to be printedIOError - if an I/O error occurs.void printOut(String s) throws IOError
String to standard-out.s - The String to be printedIOError - if an I/O error occurs.void printOut(Object o) throws IOError
Object to standard-out.o - The Object to be printedIOError - if an I/O error occurs.void printErr(char c)
throws IOError
char to standard-err.c - The char to be printedIOError - if an I/O error occurs.void printErr(String s) throws IOError
String to standard-err.s - The String to be printedIOError - if an I/O error occurs.void printErr(Object o) throws IOError
Object to standard-out.o - The Object to be printedIOError - if an I/O error occurs.void printOutLn()
throws IOError
IOError - if an I/O error occurs.void printOutLn(char c)
throws IOError
char to standard-out, then terminates the current line by writing the line separator string.c - The char to be printedIOError - if an I/O error occurs.void printOutLn(String s) throws IOError
String to standard-out, then terminates the current line by writing the line separator string.s - The String to be printedIOError - if an I/O error occurs.void printOutLn(Object o) throws IOError
Object to standard-out, then terminates the current line by writing the line separator string.o - The Object to be printedIOError - if an I/O error occurs.void printErrLn()
throws IOError
IOError - if an I/O error occurs.void printErrLn(char c)
throws IOError
char to standard-err, then terminates the current line by writing the line separator string.c - The char to be printedIOError - if an I/O error occurs.void printErrLn(String s) throws IOError
String to standard-err, then terminates the current line by writing the line separator string.s - The String to be printedIOError - if an I/O error occurs.void printErrLn(Object o) throws IOError
Object to standard-err, then terminates the current line by writing the line separator string.o - The Object to be printedIOError - if an I/O error occurs.Reader getReader()
Console.reader().PrintWriter getWriter()
InputStream in()
PrintStream out()
PrintStream err()
Copyright © 2010-2013 NWTS Java Code. All Rights Reserved. Licensed Under the Apache License version 2.0.