Constructor and Description |
---|
Prompt()
Constructs a fallback object, using System.in, System.out
for the input, output and error streams.
|
Prompt(InputStream in,
PrintStream out,
PrintStream err)
Constructs the object using the specified input and output streams.
|
Prompt(Reader in,
PrintWriter out,
PrintWriter err)
Constructs the object using the specified input and output writers.
|
Modifier and Type | Method and Description |
---|---|
String |
ask(String str)
Calls
ask(String, boolean) so that a newline
is not shown after the question shown to the user. |
String |
ask(String str,
boolean newline)
Shows the specified string to the user shows the input prompt
to the user (to indicate the user's input is expected).
|
String |
ask(String str,
String fallback)
Calls
ask(String, String, boolean) so that a newline
is not shown after the question shown to the user. |
String |
ask(String str,
String fallback,
boolean newline)
Shows the specified string to the user shows the input prompt
to the user (to indicate the user's input is expected).
|
String |
getLastLine()
Gets the latest input line that has been read.
|
static void |
main(String[] args) |
void |
setError(PrintStream err) |
void |
setError(PrintWriter err) |
void |
setInput(InputStream in) |
void |
setInput(Reader in) |
void |
setOutput(PrintStream out) |
void |
setOutput(PrintWriter out) |
void |
write(String str)
Immediately writes a string to the output.
|
void |
writeln(String str)
Immediately writes the specified string as a new line, to the output.
|
public Prompt(Reader in, PrintWriter out, PrintWriter err)
in
- the BufferedReader to use for inputout
- the PrintWriter to use for outputerr
- the PrintWriter to use for errorspublic Prompt(InputStream in, PrintStream out, PrintStream err)
in
- the BufferedReader to use for inputout
- the PrintWriter to use for outputerr
- the PrintWriter to use for errorspublic Prompt()
public String ask(String str, boolean newline)
str
- the string to show to the usernewline
- whether to print a newline after the stringpublic String ask(String str)
ask(String, boolean)
so that a newline
is not shown after the question shown to the user.public String ask(String str, String fallback, boolean newline)
str
- the string to show to the userfallback
- response to return if the user types in an
empty response (typically by simply hitting a
newline)newline
- whether to print a newline after showing the
specified string to the userpublic String ask(String str, String fallback)
ask(String, String, boolean)
so that a newline
is not shown after the question shown to the user.public void write(String str)
public void writeln(String str)
public String getLastLine()
public void setInput(InputStream in)
public void setOutput(PrintStream out)
public void setOutput(PrintWriter out)
public void setError(PrintStream err)
public void setError(PrintWriter err)