• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Input text reading

 
Lubos Komornik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Could you write me the easiest way how to obtain user input text from console after ENTER key? It must be independent on type of ENTER char, I mean cannot depend if it ends with '\r' or '\n' .

Thanks
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can read the input as given below:

InputStreamReader ir = new InputStreamReader(System.in);

hope this helps
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Lubos Komornik.

Java 5 introduced a "simple text scanner," called Scanner.
Set up a ScannerIt has lots of methods to read an int, or a double, a word or whole line, from its input. Read fuller details in the link I gave you.

CR
 
Lubos Komornik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks very helpful. thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic