日期:2014-05-16  浏览次数:20766 次

用java在linux下修改文件权限
String cmdStrs[] = new String[]{ "chmod","-R","775", "/var/www/userweb2/" + companyId + "/" + Constants.BBSFILE };

public static boolean execCmd( String[] cmdStrs ){
        try {
            Process child = Runtime.getRuntime().exec(cmdStrs);

            BufferedReader in = new BufferedReader(new InputStreamReader(child
                    .getInputStream()));

            String c = null;
            while ((c = in.readLine()) != null) {
                System.out.println(c + "<br/>");
            }
            child.waitFor();
            in.close();
        } catch (Exception e) {
            System.out.println("\n===执行linux命令出错");
            e.printStackTrace();
            return false;
        }
        return true;
    }