java下载bat文件在本地运行的办法?

如题所述

12345678910111213141516171819202122    Process process=Runtime.getRuntime().exec("cmd /c run.bat");//要执行的文件的路径为run.bat  // å¾—到输入流 InputStream inputStream=process.getInputStream(); InputStreamReader inputStreamReader=new InputStreamReader(inputStream); BufferedReader bufferedReader=new BufferedReader(inputStreamReader);   // å¾—到输出流 OutputStream outputStream=process.getOutputStream(); OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream); BufferedWriter bufferedWriter=new BufferedWriter(outputStreamWriter);   bufferedWriter.write("dd\n"); bufferedWriter.flush(); String temp=null; while((temp=bufferedReader.readLine())!=null) { System.out.println(temp);   }}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答