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); }}
温馨提示:内容为网友见解,仅供参考