日期:2014-05-17 浏览次数:20727 次
String s = "这里调用cmd命令";
System.out.println("开始转换类媒体....");
//ProcessBuilder builder = new ProcessBuilder();
//Process process = builder.command(s).redirectErrorStream(true).start();
try {
Process process = Runtime.getRuntime().exec(s);
DataInputStream errinput = new DataInputStream(process.getErrorStream());
BufferedReader errResult = new BufferedReader(new InputStreamReader(errinput));
DataInputStream input = new DataInputStream(process.getInputStream());
BufferedReader commandResult = new BufferedReader(new InputStreamReader(input));
while((errResult.readLine())!= null) {
System.out.println("逐行打印转换err信息:"+errResult.readLine());
}
process.waitFor();
System.out.println("结束转换类媒体....");
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}