2
Runtime.getRunTime.exec()を使用して複数の入力を送受信する方法を教えてください。Java Runtime.getRunTime.exec()を使用した対話型コマンド
たとえば、openSSLのようなものを実行してcsrを生成したい場合は、州、市区町村、一般名などのようなものを要求します。
Process p = Runtime.getRuntime().exec(cmd);
OutputStream out = p.getOutputStream();
//print stuff p.getInputStream();
//Now i want to send some inputs
out.write("test".getBytes());
//flush and close??? don't know what to do here
//print what ever is returned
//Now i want to send some more inputs
out.write("test2".getBytes());
//print what ever is returned.. and so on until this is complete
は、なぜあなたは()に応じてデータを送信するために使用してout.write ながら送信するために必要なものを読むためにp.getInputStream()を使用していません。
Process p = Runtime.getRuntime().exec(cmd);
OutputStream out = p.getOutputStream();
//print stuff p.getInputStream();
out.write("test".getBytes());
out.close(); //if i don't close, it will just sit there
//print stuff p.getInputStream();
out.write("test".getBytes()); // I can no longer write at this point, maybe because the outputstream was closed?
:ここ
はから取られた例です。私はもう少し説明して質問を更新します。 – boyco
フラッシュすることを忘れないでください:) – james
これはうまく動作しますが、以前はフラッシュで試してみましたが、私は非常に多くの異なるものを試していました。ありがとう! – boyco