GetOpt |
Utility loosely based on the getopt command on UNIX,
used to parse command line arguments.
Usage
Normal operation using the GetOpt class will
look something like this:
int opt;
boolean use_ID = false;
String name = null;
String pass = null;
//args is an array with the command line arguments
GetOpt myopts = new GetOpt(args,"n:p:i");
while ((opt = myopts.getopt()) != myopts.optEOF)
{
if (opt == 'i')
use_ID = true;
else if (opt == 'n')
name = myopts.optArgGet();
else if (opt == 'p')
pass = myopts.optArgGet();
else
{
//an error must have occurred
err.println(getUsageString());
return;
}
}
The format string passed to the Constructor tells GetOpt which arguments
are valid, and which ones require more information. |