PropertyPermission.newPermissionCollection() has the following syntax.
public PermissionCollection newPermissionCollection()
In the following code shows how to use PropertyPermission.newPermissionCollection() method.
//from www . ja v a 2 s .c o m import java.security.PermissionCollection; import java.util.PropertyPermission; public class Main { public static void main(String[] args) { // Build property permissions collection PropertyPermission permission = new PropertyPermission("java.*", "read"); PermissionCollection permissions = permission.newPermissionCollection(); permissions.add(permission); permissions.add(new PropertyPermission("java.home.*", "read,write")); if (permissions.implies(new PropertyPermission("java.home", "read"))) { System.out.println("Has permissions on " + "java.home" + " for read"); } if (permissions.implies(new PropertyPermission("java.home", "write"))) { System.out.println("Has permissions on " + "java.home" + " for write"); } } }
The code above generates the following result.