File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Help on Java modifications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help on Java modifications" Watch "Help on Java modifications" New topic
Author

Help on Java modifications

Troy Johnson
Greenhorn

Joined: Sep 24, 2003
Posts: 20
Hello. I am working on the following Java problem. I am making two modifications to the program. The first is to Ignore cases, which I have completed. The second is to Use a command-line argument. Could anyone offer any suggestions on using a command-line argument with this program. Thanks.

[ October 11, 2003: Message edited by: Troy Johnson ]
[ October 11, 2003: Message edited by: Troy Johnson ]
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Command-Line arguments are easy to use. Take a look at the signature for the main method:

That String array is where you receive your parameters.
(As I learned in C, I call it argv[], instead of args...)
So, the length of this array will tell you how many parameters there are, and each parameter receives its own spot in the array.
Note that, unlike in C, the program name is not passed in here. The first parameter really is the first parameter.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Try this
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help on Java modifications