• Post Reply Bookmark Topic Watch Topic
  • New Topic

to read the command prompt  RSS feed

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi people,
we can read a text file....likewise is there any possibility to read a command prompt...
thanks in advance
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to get the arguments on the command line that are typed after the name of your program, use the arguments to the main method:

Run this with, for example: java Example one two three

The easiest way to read from the console window is to use the class java.util.Scanner. For example:
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.I will try.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!