Java命令行参数处理 CLOPS

fmms 12年前
     <p>CLOPS 是一个用来处理 Java 程序中的命令行参数的类库。</p>    <p>示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">import java.io.File; import generated.WcParser; import generated.WcOptionsInterface;  public class Main {   public static void main(String[] args) throws Exception {     WcParser parser = new WcParser();     if (!parser.parse(args)) {       System.out.println("Usage: java Main [OPTIONS] file...");       System.exit(1);     }     WcOptionsInterface opt = parser.getOptionStore();     if (opt.isWordsSet())       System.out.println("I should print a word count.");     if (opt.isBytesSet())       System.out.println("I should print a byte count.");     for (File f : opt.getFiles()) checkFile(f);   }    public static void checkFile(File f) {     System.out.print("The file " + f.getPath());     if (f.exists())       System.out.println(" exists.");     else       System.out.println(" does not exist.");   } }</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326941178390" target="_blank">http://www.open-open.com/lib/view/home/1326941178390</a></p>