/** * 若資料夾不存在,則,建立資料夾 (並且授權給root:user 及更改許可權) * * @param dir_path */ public void notExistsMkDir(String dir_path) throws Exception{ File dir = new File(dir_path); if (!dir.exists()) dir.mkdir(); Runtime.getRuntime().exec("chmod 775 " + dir_path); Runtime.getRuntime().exec("chown root:user " + dir_path); } /** * 輸出為檔案 (並且授權給root:user 及更改許可權) * @param file * @param data * @throws Exception */ public void writeFile(File file,String data) throws Exception { //use commons.ioFileUtils.writeStringToFile(file, data, "UTF-8");Runtime.getRuntime().exec("chmod 664 " + file.getAbsolutePath());Runtime.getRuntime().exec("chown root:user " + file.getAbsolutePath()); }

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()