Help - Search - Members - Calendar
Full Version: Java fetching input from keyboard
MandrivaUsers.org > Advanced Topics > Command Line, Kernel and Programming
willisoften
CODE
   BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));







   double rate = Double.valueOf(keyboard.readLine()).doubleValue();




This looks so clumsy I was wondering if there was a better way to do it?

I haven't really fetched all that much input from the keyboard as I had a package from the university which did it for me. This however looks like a lot of code compared to C.
fuzzylizard
Not really. Getting keyboard input from the command line in Java is a rather clumsy thing and setting up stream readers is really the only way of doing it. However, once you start doing GUI programming, things become a lot easier.

If you want a link detailing the different ways of doing I/O in java check this out:


http://www.fuzzylizard.com/articles/java-io.cfm
willisoften
Thanks,
I was just wondering -think I'll set up my own class for input then.

The one I got from the university doesn't work with Linux though it should so I was trying to do input myself.

Cheers

Will

Ps Thanks for the link too
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.