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
Author

Input text reading

Lubos Komornik
Greenhorn

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' .

Thanks
Srikanth Ramu
Ranch Hand

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

InputStreamReader ir = new InputStreamReader(System.in);

hope this helps
Campbell Ritchie
Sheriff

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

Joined: Mar 27, 2007
Posts: 2
It looks very helpful. thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
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)?