2

I'm trying to create a process in java that starts a external file that asks for a number of arguments which the user gives at execution time.

The question is how to determine if the precess is asking for a argument

    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();
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
unfamous
  • 611
  • 1
  • 5
  • 14
  • 2
    Perhaps you should listen and respond to the process's InputStream, and hopefully it will send something when it wants to accept data (this all depends on the process of course). – Hovercraft Full Of Eels May 26 '12 at 11:50
  • Possible duplicate ? : http://stackoverflow.com/questions/5826070/java-runtime-process-check-if-waiting-for-input – Kazekage Gaara May 26 '12 at 11:57

0 Answers0