0

How can I achieve the following in Apache Commons Exec? (There doesn't seem to be any documentation for this use case).

  1. Launch a child process.
  2. Pass the child process a string on its stdin.
  3. Wait for the child process to terminate.
  4. Collect the stdout from the child process as a string.
user3364825
  • 1,541
  • 1
  • 15
  • 23

1 Answers1

-1

Use Executor#setStreamHandler(...) to handle input/output redirection.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • I did see that method, but it's not particularly clear how it's used. Could you perhaps provide an example of reading / writing on stdin/out? – user3364825 Jul 21 '14 at 20:51
  • I suggest you delve more deeply into exploring the Javadoc and the API. On StackOverflow you are expected to do most of the work yourself and ask for help after having expended significant effort to solve the problem yourself. – Jim Garrison Jul 21 '14 at 21:16
  • Sheesh. If you don't want to help, don't bother posting an "answer". – user3364825 Jul 21 '14 at 21:43