This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Input text reading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Input text reading" Watch "Input text reading" New topic

Input text reading

Lubos Komornik

Joined: Mar 27, 2007
Posts: 2
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' .

Srikanth Ramu
Ranch Hand

Joined: Feb 20, 2007
Posts: 76
you can read the input as given below:

InputStreamReader ir = new InputStreamReader(;

hope this helps
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36598
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.

Lubos Komornik

Joined: Mar 27, 2007
Posts: 2
It looks very helpful. thanks
I agree. Here's the link:
subject: Input text reading
Similar Threads
Key Event listener question.
My Shopping cart does not work
How to take input from screen automatically
capturing variable in "value" field of the form
Best way to create a combo-box (editable selectBox)?