标签:
java操作windows命令(Rar.exe)执行文件压缩
// String srcPath = "D:\\test";// 被压缩文件夹 String srcPath = "D:\\test.txt";// 被压缩文件 String destPath = "D:\\test.rar";// 压缩后文件 String rarexePath = "C:\\Program Files\\WinRAR\\Rar.exe"; // 电脑系统中WinRAR安装路径 未安装出错 String[] rarcmd = { rarexePath, "a", destPath, srcPath }; Runtime rt = Runtime.getRuntime(); rt.exec(rarcmd);
java操作windows命令(UnRAR.exe)执行文件解压缩
String srcPath = "D:\\test.rar";// 压缩文件 String destPath = "D:\\";// 解压缩后路径 String unrarexePath = "C:\\Program Files\\WinRAR\\UnRAR.exe"; // 电脑系统中WinRAR安装路径 未安装出错 String[] unrarcmd = { unrarexePath, "x", srcPath, destPath }; Runtime rt = Runtime.getRuntime(); rt.exec(unrarcmd);
标签:
原文地址:http://www.cnblogs.com/pumushan/p/5653890.html