Getting input from the command line?
I am looking for examples or information about getting input in to a program from the command line. I know that the command line would read like this:
java CoffeeHouse Coffee.dat
whereCoffeeHouse is the class I want to execute andCoffee.dat is a data file I want to use.
It seems that the String[] args in main would be the way to get it in but I'm not sure.
[407 byte] By [
Palmera] at [2007-10-2 7:03:53]

The args array in main(): public class MainArgs {
public static void main(String[] args) throws Exception {
for (int ix = 0; ix < args.length; ix++) {
System.out.println("-->" + args[ix] + "<--");
}
}
}
:; java -cp classes MainArgs a "b c d" e f g
-->a<--
-->b c d<--
-->e<--
-->f<--
-->g<--
jverda at 2007-7-16 20:34:34 >

> Or do you mean how to read the contents of the file?
>
> http://java.sun.com/docs/books/tutorial/essential/io/i
> ndex.html
I can read the contents of the file if I hardcode the file name in the reader. So I'm guessing if I try what you suggested in your first response , it will work. Thank you. I'll post again if I can't get it.