public class CommandLineArgs { @Name("-input") @Required private String input; @Name("-output") private String output = "."; public CommandLineArgs() {} // getter and setter methods } public class Main { public static void main(String[] args) { CommandLineArgs commandLineArgs = new CommandLineArgs(); LineArgsParser parser = new LineArgsParser(commandLineArgs); parser.parse(args); } } public class Main { public static void main(String[] args) { Options options = new Options(); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); String input = cmd.getOptionValue("input"); String output = cmd.getOptionValue("output", "."); } }


上一篇:
下一篇:
切换中文