java如何知道进程是否在等待输入

时间:2012-05-26 11:48:28

标签: java

我正在尝试在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();

0 个答案:

没有答案