Jump to content

Java fetching input from keyboard


Recommended Posts

    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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...