您不能
Runtime.getRuntime().exec()像在示例中那样在内部使用PIPE 。PIPE是shell的一部分。
你可以做
- 将命令放入shell脚本并使用
.exec()
或执行该shell脚本 - 您可以执行类似以下操作
String[] cmd = { "/bin/bash", "-c", "echo password | python script.py '" + packet.toString() + "'"};Runtime.getRuntime().exec(cmd);


