Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Reading / Parsing Command Line options using apache.commons.cli

public static void main(String[] args) {
   Option option1 = OptionBuilder.withArgName("option").hasArg().create("option");

   Options options = new Options();
   CommandLineParser parser = new GnuParser();
   options.addOption(option1);

   final CommandLine commandLine = parser.parse(options, args);
   final String[] commandLineArgs = commandLine.getArgs();

   if (commandLine.hasOption("option")) {
   }
}

   Like      Feedback     Parsing Command Line options  apache.commons.cli  CommandLineParser  GnuParser  OptionBuilder  Options



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner