得到反馈后,我运行程序但在控制台中没有输出
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.io.InputStream;
class pbdemo {
static public void main(String[] args) throws Exception {
String s;
ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/f", "dir");
pb.directory(new File("C:\\ljava"));
try {
Process pro = pb.start();
pro.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while ((s = br.readLine()) != null) {
System.out.println("here we go" + s);
}
} catch (Exception e) {
System.out.println("sorry" + e);
}
}
}
程序运行但没有输出。