class="java">
try {
Process process = Runtime.getRuntime().exec("su"); //以管理员身份运行
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("tar -jxvf /home/kylin/license/test.cpk -C ./test2\n"); //执行命令1:将test.cpk文件解压到当前目录的test2文件夹下
os.writeBytes("exit\n"); //执行命令2:退出操作
os.flush();
process.waitFor(); //这一步很重要:直至解压缩操作执行完成后,才执行下面的操作。否则,没有添加此句的话,在后续操作中如果要引用解压后的文件,就会由于未解压完成而找不到文件报错。
//后续操作
checkLicenseContent(resBean, licenseFileContent, false, null);
} catch (Exception e) {
e.printStackTrace();
}