2

我正在尝试在 java 中创建一个进程,该进程启动一个外部文件,该文件要求用户在执行时提供一些参数。

问题是如何确定进动是否要求争论

    ProcessBuilder pb = new ProcessBuilder(c.fileName);
    Process proc = null;
    try {
        proc = pb.start();
    } catch (IOException ex) {
        Logger.getLogger(clas.class.getName()).log(Level.SEVERE, null, ex);
    }
    Scanner in = new Scanner(proc.getInputStream());
    PrintWriter out = null;
    out = new PrintWriter(proc.getOutputStream());
    while (in.hasNextLine()) {
        System.out.println(in.nextLine());
        out.println(1); // i don't want to give 1 untill the process need it ! 
        out.flush();
    }

    out.close();
4

0 回答 0