/* * CmdLine.java -- A very simple demonstration of how to access any * command-line arguments provided when the program was executed. * * To compile and execute a Java application from the command line: * $ javac CmdLine.java * $ java CmdLine * If the user wants to supply some information for the program to use, * without having to wait for the program to prompt for it, the programmer * may have made it possible for the user to type the information after * the program name on the command * line. For example: * $ java CmdLine a bouncy "string of stuff" * If the code is written to accept info in this manner, it can speed up * common functionality for the user. This isn't as generally useful in * Java, given its Internet focus, than in other languages (such as C). * * UNIX command line utilities use this mechanism frequently. Example: * $ ls -l * For that matter, the string "CmdLine" is actually a command-line * argument to Java. */ import java.io.*; public class CmdLine { public static void main (String [] args) { if (args.length > 0) { for (int i=0; i"); } } }