Java调用批处理或可执行文件

 import java.io.BufferedReader;
import java.io.InputStreamReader; public class Test {
  public static void main(String[] args) {
    String command = "cmd /c dir \\windows";
    String result;
    try {
      Process process = Runtime.getRuntime().exec(command);
      BufferedReader bufferedReader = new BufferedReader(
      new InputStreamReader(process.getInputStream()));
      while ((result = bufferedReader.readLine()) != null){
        System.out.println(result);
14        }
      process.waitFor();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
上一篇:IReport问题整理


下一篇:Jquery easyUI datagrid遇到空行做判断