|
Question
|
How do I read text from standard input?
|
|
Topics
|
Java:API:IO
|
|
Author
|
John Zukowski PREMIUM
|
|
Created
|
Jul 9, 2000
|
Modified
|
Aug 18, 2001
|
|
Answer
System.in is the InputStream for standard input. The following demonstrating reading from it a line at a time:
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(isr);
String line = null;
while ((line = reader.readLine()) != null) {
// Process line
}
Is this item
helpful? yes no
Previous votes Yes: 1 No: 0
|
|
Comments and alternative answers
|
|
 |
|