• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to feed Input from keyboard?

 
Saptaparna Dhar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Saptaparna Dhar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic