toxa_1995
@toxa_1995
Начинающий...

В чем проблема??

Кидаю следующий код, при вызове через терминал, выводит null, по всем 4 аргументам. Есть другой проект, работает все отлично.
private static String FILEOUT;
    private static Integer FILEROW;
    private static Integer FILECOL;
    private static Integer FILELEN;

    public static String getFILEOUT(){
        return FILEOUT;
    }

    public static Integer getFILEROW(){
        return FILEROW;
    }

    public static Integer getFILECOL(){
        return FILECOL;
    }

    public static Integer getFILELEN(){
        return FILELEN;
    }

    public Parameters(String[] args) throws ParseException {
        Option optionOut = new Option("out", true, "Выходной файл");
        optionOut.setArgs(1);
        //optionOut.setRequired(true);

        Option optionROW = new Option("row", true, "Число строк");
        optionROW.setArgs(1);
        //optionROW.setRequired(true);

        Option optionCOL = new Option("col", true, "Число столбцов");
        optionCOL.setArgs(1);
        //optionCOL.setRequired(true);

        Option optionLEN = new Option("len", true, "Максимальная длина");
        optionLEN.setArgs(1);
       // optionLEN.setRequired(true);

        Options options = new Options();

        options.addOption(optionOut);
        options.addOption(optionROW);
        options.addOption(optionCOL);
        options.addOption(optionLEN);


        CommandLineParser commandLineParser = new PosixParser();

        CommandLine commandLine = commandLineParser.parse(options, args);

        if (commandLine.hasOption("out"))
            FILEOUT = commandLine.getOptionValue("out");

        if (commandLine.hasOption("row"))
            FILEROW = Integer.parseInt(commandLine.getOptionValue("row"));

        if (commandLine.hasOption("col"))
            FILECOL = Integer.parseInt(commandLine.getOptionValue("col"));

        if (commandLine.hasOption("len"))
            FILELEN = Integer.parseInt(commandLine.getOptionValue("len"));
    }

1ab7e9ed97384db59cb2555e0f6cf9e3.png
  • Вопрос задан
  • 178 просмотров
Решения вопроса 1
toxa_1995
@toxa_1995 Автор вопроса
Начинающий...
Понял почему не идет. Я не получаю аргументы из public static void main(String[] args){...}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы