FileDocCategorySizeDatePackage
GetOptSimple.javaAPI DocExample814Mon Feb 26 11:08:26 GMT 2001None

GetOptSimple

public class GetOptSimple extends Object
Trivial demonstration of GetOpt. If -h present, print help.
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: GetOptSimple.java,v 1.1 2001/02/26 16:08:27 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
static voidhelpAndExit(int returnValue)
Stub for providing help on usage You can write a longer help than this, certainly.

		System.err.println("This would tell you how to use this program");
		System.exit(returnValue);
	
public static voidmain(java.lang.String[] args)

		GetOpt go = new GetOpt("h");
		char c;
		while ((c =go.getopt(args)) != 0) {
			switch(c) {
			case 'h":
				helpAndExit(0);
				break;
			default:
				System.err.println("Unknown option in " +
					args[go.getOptInd()-1]);
				helpAndExit(1);
			}
		}
		System.out.println();