从java中调用DOS命令行并ath输出结果的方法.docVIP

  • 14
  • 0
  • 约小于1千字
  • 约 1页
  • 2020-12-13 发布于黑龙江
  • 举报

从java中调用DOS命令行并ath输出结果的方法.doc

从java中调用DOS命令行并catch输出结果的方法 // works for DOS String cmds[] = new String[2]; cmds[0] = dir; // replace with ls on UNIX cmds[1] = c:; // replace with / on UNIX // execute the command Process pro = Runtime.getRuntime().exec(cmds); // wait until its done executing pro.waitFor(); // what did the process output from the Input pipe back to // this process (okay, who named this stuff)? InputStream out = pro.getInputStream(); // output it (really slowly) int i; while ((i = out.read()) != -1) System.out.println((char) i);

文档评论(0)

1亿VIP精品文档

相关文档