M
metfan
Hi,
Sorry, the title may not be clear. Let me describe my question.
I wrote a program to read from the console, say, System.in,
BufferedReader userInput = new BufferedReader(new
InputStreamReader(System.in));
String inputStr;
for (; {
try {
inputStr = userInput.readLine();
if (inputStr != null) {
System.out.println(inputStr);
}
} catch (Exception e) {
}
}
if the use input some data, for example, the user input
"Hello!" and press return, the code would print a line "Hello!",
now what I'm going to do is to simulate that the user has
input some extra data from console, for example, if the user
input "Hello!", the code above would print 2 lines:
Hello!
World!
And no, what I want is not a snip like:
try {
inputStr = userInput.readLine();
if (inputStr != null) {
System.out.println(inputStr);
}
inputStr = "World!";
System.out.println(inputStr);
} ...
What I really want is to simulate the date input by user from console,
did I make myself clear? and is that possible? sorry if my question
looks too newbie to you.
Sorry, the title may not be clear. Let me describe my question.
I wrote a program to read from the console, say, System.in,
BufferedReader userInput = new BufferedReader(new
InputStreamReader(System.in));
String inputStr;
for (; {
try {
inputStr = userInput.readLine();
if (inputStr != null) {
System.out.println(inputStr);
}
} catch (Exception e) {
}
}
if the use input some data, for example, the user input
"Hello!" and press return, the code would print a line "Hello!",
now what I'm going to do is to simulate that the user has
input some extra data from console, for example, if the user
input "Hello!", the code above would print 2 lines:
Hello!
World!
And no, what I want is not a snip like:
try {
inputStr = userInput.readLine();
if (inputStr != null) {
System.out.println(inputStr);
}
inputStr = "World!";
System.out.println(inputStr);
} ...
What I really want is to simulate the date input by user from console,
did I make myself clear? and is that possible? sorry if my question
looks too newbie to you.