This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes input and output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "input and output" Watch "input and output" New topic
Author

input and output

ravi rajasekhar
Greenhorn

Joined: Dec 21, 2000
Posts: 1
Please help me in asking the user to enter text, an int, long etc. That is , how do we accept input from the user. The input can be of any data type., including objects. Is there a mechanism of cin and cout like in c++. In fact, I want to teach my students asking for input in their programs like the way C++ does. How can we do the sam in JFc and AWT? Please help me as fast as U can.
Ron Pac
Greenhorn

Joined: Dec 26, 2000
Posts: 7
I think the weakest part of my Java programming is the I/O. In fact there are huge books about this subject which I have not been able to read up on.
I'm not sure if there is a class the is advance enough to return the correct data type (String, int, float) that is needed....
Here is how I would read in an integer:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String someStr = null;
int someInt = 0;
try {
someStr = in.readLine();
someInt = Integer.parseInt(someStr, 10);
}
catch (IOException e) { }
I guess you'd have to do this for all data types if there are no other ways.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: input and output
 
It's not a secret anymore!