This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to read int or any input value entered in console using DataInputStream?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "how to read int or any input value entered in console using DataInputStream??" Watch "how to read int or any input value entered in console using DataInputStream??" New topic
Author

how to read int or any input value entered in console using DataInputStream??

prasad kakani
Ranch Hand

Joined: Jul 15, 2008
Posts: 59
Hello

Could you please tell me how to read the int or any input value which is entered in console while executing the program, using DataInputStream..

suppose System.out.println("Enter the Range:");
DataInputStream dis = new DataInputStream(System.in);
int range = dis.read();
System.out.println("The range is "+ range);

i think i am doing something wrong here..please suggest me..
Thanks
Prasad
Christian Zillmann
Greenhorn

Joined: Jun 24, 2009
Posts: 2
Why using DataInputStream for that ?
Gareth Lloyd
Greenhorn

Joined: Jun 25, 2009
Posts: 5
Hey, I think you need to use readInt() rather than read()

Take a look at the JavaDoc for DataInputStream's various methods:

http://java.sun.com/j2se/1.5.0/docs/api/java/io/DataInputStream.html
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to read int or any input value entered in console using DataInputStream??
 
Similar Threads
about DataInputStream class
DataInputStream problem
Regarding reading a file in a jsp
ArrayList in jsp using JSTL and springs
chat programe, kindly see the code and help me.