Java.util.PropertyPermission.getActions() Method
Advertisements
Description
The java.util.PropertyPermission.getActions() method returns the list of present actions in a string representation (e.g. "read,write").
Declaration
Following is the declaration for java.util.PropertyPermission.getActions() method
public String getActions()
Parameters
NAReturn Value
This method returns the string representation of the actions (e.g. "read,write").
Exception
NAExample
The following example shows the usage of java.util.PropertyPermission.getActions() method.
package com.tutorialspoint;
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");
}
}
}
Let us compile and run the above program, this will produce the following result:
Has permissions on java.home.usr for read Has permissions on java.home.usr for write