Java.util.PropertyPermission.getActions() 方法
package com.codingdict;
import java.util.PropertyPermission;
public class PropertyPermissionDemo {
private static PropertyPermission permission;
public static void main(String[] args) {
// Build property permissions
permission = new PropertyPermission("java.home.*", "read,write");
// Check permissions
checkFilePermissions("java.home.usr");
}
private static void checkFilePermissions(String path) {
// Check permission given name
if(path.matches(permission.getName())) {
// Get actions list
String actions = permission.getActions();
// Match read write actions
if(actions.contains("read"))
System.out.println("Has permissions on "+path+" for read");
if(actions.contains("write"))
System.out.println("Has permissions on "+path+" for write");
}
}
}