的朋友,我不得不放棄「 - 」作爲選項參數在如何給連字符作爲選項參數,在getopt的類
的Getopt類下面
Getopt g = new Getopt("cm_log_parser", args, "i:s"); //-D to enable debug log while((opt = g.getopt()) != -1) { switch (opt) { case 'f'://To set file name(if above is not specified) fileNameWithPath = getAndCheckOptArg(fFlag, opt, g); fFlag = true; break; case 's'://To set the header String separator = getAndCheckOptArg(hFlag, opt, g); hFlag = true; breakk; case '?': usage("Invalid option" + opt + " option"); break; } }
我的代碼給出
在我想作爲-s「 - 」的參數中,但它顯示了一些錯誤,如無效選項有沒有辦法做到這一點?