java 获取文件权限信息吗_如何在Java中以编程方式获取文件权限模式
在Android中使用chmodJava没有像chmod这样的平台相关操作的原生支持.但是,Android通过android.os.FileUtils为其中一些操作提供实用程序. FileUtils类不是公共SDK的一部分,因此不受支持.因此,使用此风险需要您自担风险:public int chmod(File path, int mode) throws Exception {Class fil
·
在
Android中使用chmod
Java没有像chmod这样的平台相关操作的原生支持.但是,Android通过android.os.FileUtils为其中一些操作提供实用程序. FileUtils类不是公共SDK的一部分,因此不受支持.因此,使用此风险需要您自担风险:
public int chmod(File path, int mode) throws Exception {
Class fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions =
fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
return (Integer) setPermissions.invoke(null, path.getAbsolutePath(), mode, -1, -1);
}
...
chmod("/foo/bar/baz", 0755);
...
更多推荐



所有评论(0)