점진적인 개선
- 명령행 인수의 구문을 분석하는 Args 유틸을 점진적으로 개선해봅니다.
- 간단한 Args 사용법입니다.
public static void main(String[] args) {
try {
Args arg = new Args("l,p#,d*", args);
boolean logging = arg.getBoolean('l');
int port = arg.getInt('p');
String directory = arg.getString('d');
executeApplication(logging, port, directory);
} catch (Exception e) {
System.out.printf("Argument error: %s\n", e.errorMessage());
}
}
- 매개변수 두 개로 Args 클래스의 인스턴스를 생성