Package de.audioattack.io
Class ConsolePrintDecorator
java.lang.Object
de.audioattack.io.ConsolePrintDecorator
- All Implemented Interfaces:
Console,Flushable,Appendable
Contains convenience methods which make usage of
de.audioattack.io.Console as easy as using
PrintStream.- Since:
- 1.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Appends the specified character.append(CharSequence charSequence) Appends the specified character sequence.append(CharSequence charSequence, int start, int end) Appends a subsequence of the specified character sequence.booleanFlushes the underlying stream and checks its error state.voidflush()Flushes this ConsoleStringDecorator by writing any buffered output.Writes formatted String.Writes formatted String.voidprint(boolean b) Prints a boolean value.voidprint(char c) Prints a character.voidprint(char[] s) Prints a character array.voidprint(double d) Prints a double-precision floating-point number.voidprint(float f) Prints a floating-point number.voidprint(int i) Prints an integer.voidprint(long l) Prints a long integer.voidPrints an object.voidPrints a string.Convenience method which writes formatted String.Convenience method which writes formatted String.voidprintln()Terminates the current line by writing the line separator string.voidprintln(boolean b) Prints a boolean value and then terminates the line.voidprintln(char c) Prints a character and then terminates the line.voidprintln(char[] s) Prints a character array and then terminates the line.voidprintln(double d) Prints a double-precision floating-point number and then terminates the line.voidprintln(float f) Prints a floating-point number and then terminates the line.voidprintln(int i) Prints an integer and then terminates the line.voidprintln(long l) Prints a long integer and then terminates the line.voidPrints an object and then terminates the line.voidPrints a string and then terminates the line.reader()Gets aReaderassociated with the console.readLine()Reads single line.Writes formatted prompt and reads single line.char[]Reads password.char[]readPassword(String fmt, Object... args) Writes formatted prompt and reads password.writer()Gets aPrintWriterassociated with the console.
-
Constructor Details
-
ConsolePrintDecorator
Constructor.- Parameters:
console- the console to which data will be written
-
-
Method Details
-
reader
Gets aReaderassociated with the console. Invokingclose()on this object will not close the underlying stream. -
writer
Gets aPrintWriterassociated with the console. Invokingclose()on this object will not close the underlying stream. -
format
Writes formatted String. -
format
Writes formatted String.- Parameters:
locale- The locale to apply during formatting. If it isnullthen no localization is applied.fmt- format Stringargs- arguments to replace format specifiers in format String- Returns:
- this ConsolePrintDecorator
-
print
public void print(boolean b) Prints a boolean value.- Parameters:
b- boolean to be printed
-
print
public void print(char c) Prints a character.- Parameters:
c- character to be printed
-
print
public void print(char[] s) Prints a character array.- Parameters:
s- character array to be printed
-
print
public void print(double d) Prints a double-precision floating-point number.- Parameters:
d- double-precision floating-point number to be printed
-
print
public void print(float f) Prints a floating-point number.- Parameters:
f- floating-point number to be printed
-
print
public void print(int i) Prints an integer.- Parameters:
i- the integer to be printed
-
print
public void print(long l) Prints a long integer.- Parameters:
l- the long integer to be printed
-
print
Prints an object.- Parameters:
o- the object to be printed
-
print
Prints a string.- Parameters:
s- the string to be printed
-
printf
Convenience method which writes formatted String.- Parameters:
locale- The locale to apply during formatting. If it isnullthen no localization is applied.fmt- format Stringargs- arguments to replace format specifiers in format String- Returns:
- this ConsolePrintDecorator
-
printf
Convenience method which writes formatted String. -
println
public void println()Terminates the current line by writing the line separator string. -
println
public void println(boolean b) Prints a boolean value and then terminates the line.- Parameters:
b- boolean to be printed
-
println
public void println(char c) Prints a character and then terminates the line.- Parameters:
c- character to be printed
-
println
public void println(char[] s) Prints a character array and then terminates the line.- Parameters:
s- character array to be printed
-
println
public void println(double d) Prints a double-precision floating-point number and then terminates the line.- Parameters:
d- double-precision floating-point number to be printed
-
println
public void println(float f) Prints a floating-point number and then terminates the line.- Parameters:
f- floating-point number to be printed
-
println
public void println(int i) Prints an integer and then terminates the line.- Parameters:
i- the integer to be printed
-
println
public void println(long l) Prints a long integer and then terminates the line.- Parameters:
l- the long integer to be printed
-
println
Prints an object and then terminates the line.- Parameters:
o- the object to be printed
-
println
Prints a string and then terminates the line.- Parameters:
s- the string to be printed
-
readLine
Writes formatted prompt and reads single line. -
readLine
Reads single line. -
readPassword
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:
readPasswordin interfaceConsole- Parameters:
fmt- format Stringargs- 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:
readPasswordin interfaceConsole- Returns:
- the password
- See Also:
-
flush
public void flush()Flushes this ConsoleStringDecorator by writing any buffered output. -
append
Appends the specified character sequence.- Specified by:
appendin interfaceAppendable- Parameters:
charSequence- the character sequence to append. IfcharSequenceisnull, then the four characters "null" are appended
-
append
Appends a subsequence of the specified character sequence.- Specified by:
appendin interfaceAppendable- Parameters:
charSequence- the character sequence to append. IfcharSequenceisnull, then characters will be appended as ifcharSequencecontained the four characters "null".start- index of the first character in the subsequenceend- index of the character following the last character in the subsequence
-
append
Appends the specified character.- Specified by:
appendin interfaceAppendable- Parameters:
c- the character to append
-
checkError
public boolean checkError()Flushes the underlying stream and checks its error state. Error state is set totrueif underlying stream has encountered anIOExceptionother than .InterruptedIOException- Returns:
trueif underlying stream has encountered anIOException, elsefalse
-