public static void main(String[] args) {
try {
// 执行ping命令
Process process = Runtime.getRuntime().exec("cmd /c e:&dir");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK")));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
网友评论