我试图弄清楚如何使用ProcessBuilder
. 这个微不足道dir
的甚至不起作用。我究竟做错了什么?
Process pb = new ProcessBuilder("cmd","dir C:\\").start();
InputStream in = pb.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
输出只有:
Microsoft Windows XP [版本 5.1.2600] (C) 版权所有 1985-2001 Microsoft Corp.