wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to feed Input from keyboard? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to feed Input from keyboard?" Watch "How to feed Input from keyboard?" New topic
Author

How to feed Input from keyboard?

Saptaparna Dhar
Greenhorn

Joined: Sep 16, 2011
Posts: 10
Hi,
I am trying out simple programs like-- to find GCD etc. Can you please tell me how can a user feed input from keyboard in command prompt/in java.I have searched in google,but could not understand properly.It being my first day of programming in java,I am not getting how to use KeyboardReader or Scanner class.Which package do I need to import to work with either of these?
Please suggest an easy way to feed the input data
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
You have a java program you are running on the command line correct? And you want to read user input from the command line?


Here's an example if that's your question:

http://www.roseindia.net/java/java-get-example/java-get-user-input.shtml
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Creating a java.util.Scanner around System.in will also work, and if you run your program from an actual command line (not an IDE) you can also use System.console().


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Saptaparna Dhar
Greenhorn

Joined: Sep 16, 2011
Posts: 10
Thank you both.
My problem is solved and I found the tips to be really useful.I know these are the most basic things in Java.But for a child, alphabet series appears to be the most difficult thing invented.So is in my case.
Thank you again.
 
Don't get me started about those stupid light bulbs.
 
subject: How to feed Input from keyboard?
 
Similar Threads
Not able to get Live Feed of JavaRanch
read in an integer
read in an integer
read in an integer
Input from a keyboard