/**
*
* @param fileName
* 压缩文件路径
* @param RARRealpath
* 压缩后的文件路径
* @throws Exception
*/
public static void RARFile(String fileName, String RARRealpath)
throws Exception {
if (fileName == null) {
return;
}
fileName = fileName.trim();
if (fileName.equals("")) {
return;
}
// winRAR程序路径
String RARCMD = "C://Program Files//WinRAR//Rar.exe a -ep";
String exec = RARCMD + " " + RARRealpath + " " + fileName;
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(exec);
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream(), "gbk"));
@SuppressWarnings("unused")
String line;
while ((line = br.readLine()) != null) {
// System.out.println(line);
}
br = new BufferedReader(
new InputStreamReader(p.getErrorStream(), "gbk"));
while ((line = br.readLine()) != null) {
// System.err.println(line);
}
// 当前线程等待该process结束,既挂起主线程
p.waitFor();
}
09-01