Проверьте их:
Или самокрутка:
Например, это - то, как Вы используете commons-cli
проанализировать 2 аргумента строки:
import org.apache.commons.cli.*;
public class Main {
public static void main(String[] args) throws Exception {
Options options = new Options();
Option input = new Option("i", "input", true, "input file path");
input.setRequired(true);
options.addOption(input);
Option output = new Option("o", "output", true, "output file");
output.setRequired(true);
options.addOption(output);
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("utility-name", options);
System.exit(1);
}
String inputFilePath = cmd.getOptionValue("input");
String outputFilePath = cmd.getOptionValue("output");
System.out.println(inputFilePath);
System.out.println(outputFilePath);
}
}
использование из командной строки:
$> java -jar target/my-utility.jar -i asd
Missing required option: o
usage: utility-name
-i,--input input file path
-o,--output output file
Приложение .DoEvents
обычно используется, чтобы гарантировать, что события обрабатываются периодически, когда вы выполняете какую-либо длительную операцию в потоке пользовательского интерфейса.
Лучшее решение - просто не делать этого. Выполняйте длительные операции с отдельными потоками, маршализуя их в поток пользовательского интерфейса (либо с помощью Control.BeginInvoke
/ Invoke
, либо с помощью BackgroundWorker
), когда вам нужно обновить UI.
Application.DoEvents
вводит возможность повторного входа,
Имхо, вам лучше никогда не использовать его, так как вы можете столкнуться с очень неожиданным поведением. Just generated code is ok. Things like you are executing again the event handler you are currently in,because the user pressed a key twice etc etc. If you want to refresh a control to display the current process you should explicitly call .Update on that control in instead of calling Application.DoEvents.