jQuery in Action, 2nd edition*
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
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: 38107
    
  22
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
capturing variable in "value" field of the form
How to take input from screen automatically
Best way to create a combo-box (editable selectBox)?
Key Event listener question.
My Shopping cart does not work