public static void main(String[] args) throws Exception
{
Process process = Runtime.getRuntime().exec("ipconfig -all");
//获取执行结果输出
InputStream is = process.getInputStream();
BufferedReader bufr = new BufferedReader(new InputStreamReader(is, "GBK"));
String len = "";
while((len = bufr.readLine()) != null)
{
System.out.println(len);
}
}
}
复制代码
作者: Maple 时间: 2014-2-25 16:12
Process process = Runtime.getRuntime().exec("cmd /c dir c:\\folder");
你在cmd里打dir /? 就可以查看运行dir命令的一些参数,在dir后面写上目录名称,可以直接打印出那个目录的结构