Java调用windows程序

Java调用windows程序
     Runtime ru = Runtime.getRuntime();
        try {
            //调用播放器文件播放指定MP3
            Process p1 = ru.exec("C:\\Program Files\\Windows Media Player\\wmplayer d:\\DADA\\mp3\\0197.mp3");
           //调用批处理文件 
            Process p2 = ru.exec("d:\\a.bat");

            //显示执行结果
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while((line=br.readLine())!=null){
                System.out.println(line);
            }
        } catch (IOException ex) {ex.printStackTrace();}

你可能感兴趣的:(Java调用windows程序)