I need to execute a command in my java program but after executing the command , it required another parameter ( a password in my case ). how can I manage the output process of Runtime.getRuntime().exec()
to accept parameter for further execution ?
I tried new BufferedWriter(new OutputStreamWriter(signingProcess.getOutputStream())).write("123456");
but it did not work.
Best Answer
Does your program not feature a --password option ? Normally all command line based programs do, mainly for scripts.
Or the more complicated way and much more error-prone:
This sample opens a new thread (keep in mind concurrency and synchronisation) that's going to read the output of your process. Similar you can feed your process with input as long as it has not terminated:
Hope this helps.