Process的问题# Java - 爪哇娇娃
j*s
1 楼
想实现“ls -l | sort”
开两个进程,一个运行ls -l,另一个运行sort,进程1的输出作为进程2的输入,可是
似乎
进程2没收到,谁能帮我看看下面代码的问题?
public void runStep0(){
try {
Process proc1 = Runtime.getRuntime().exec("ls -l");
InputStream stdin1 = proc1.getInputStream(); //
InputStreamReader isr1 = new InputStreamReader(stdin1);
BufferedReader br1 = new BufferedReader(isr1);
Process proc2 = Runtime.getRuntime().exec("sort");
InputStream stdin2 = proc1.getInputStream();
开两个进程,一个运行ls -l,另一个运行sort,进程1的输出作为进程2的输入,可是
似乎
进程2没收到,谁能帮我看看下面代码的问题?
public void runStep0(){
try {
Process proc1 = Runtime.getRuntime().exec("ls -l");
InputStream stdin1 = proc1.getInputStream(); //
InputStreamReader isr1 = new InputStreamReader(stdin1);
BufferedReader br1 = new BufferedReader(isr1);
Process proc2 = Runtime.getRuntime().exec("sort");
InputStream stdin2 = proc1.getInputStream();