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;
try {
ProcessBuilder pb = new ProcessBuilder("cmd", "/f", "dir");
pb.directory(new File("F:\\WINDOWS"));
pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(pb.getInputStream()));
while ((s = br.readLine()) != null)
System.out.println(s);
} catch (Exception e) {
System.out.println("sorry" + e);
}
}
}
有什么问题
BufferedReader br=new BufferedReader(new InputStreamReader(pb.getInputStream()));
我得到找不到符号错误。