File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 46320
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
jQuery in Action, 3rd edition