SHARE
TWEET

Untitled

a guest May 26th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class FileUtil {
  2.   public static void chmod(String path, int mode) throws Exception {
  3.     if (Build.VERSION.SDK_INT >= Build.VERSION_CODE.LOLLIPOP) {
  4.       try {
  5.         Os.chmod(path,mode);
  6.       } catch (Exception e) {
  7.       // ignore
  8.       }
  9.     }
  10.    
  11.     File file = new File(path);
  12.     String cmd = "chmod ";
  13.     if (file.isDirectory()){
  14.       cmd += " -R ";
  15.     }
  16.    
  17.     // %o:整数类型(八进制)
  18.     String cmode = String.format("%o", mode);
  19.     Runtime.getRuntime().exec(cmd + cmode + " " + path).waitFor();
  20.    
  21.   }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top