Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FileUtil {
- public static void chmod(String path, int mode) throws Exception {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODE.LOLLIPOP) {
- try {
- Os.chmod(path,mode);
- } catch (Exception e) {
- // ignore
- }
- }
- File file = new File(path);
- String cmd = "chmod ";
- if (file.isDirectory()){
- cmd += " -R ";
- }
- // %o:整数类型(八进制)
- String cmode = String.format("%o", mode);
- Runtime.getRuntime().exec(cmd + cmode + " " + path).waitFor();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement