- Java.util 包类
- Java.util - 首页
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util 包补充
- Java.util - 接口
- Java.util - 异常
- Java.util - 枚举
- Java.util 有用资源
- Java.util - 有用资源
- Java.util - 讨论
Java PropertyPermission getActions() 方法
描述
java PropertyPermission getActions() 方法返回以字符串形式表示的现有操作列表(例如,“read,write”)。
声明
以下是java.util.PropertyPermission.getActions() 方法的声明
public String getActions()
参数
无
返回值
此方法返回操作的字符串表示形式(例如,“read,write”)。
异常
无
检查 PropertyPermission 实例的读取访问权限示例
以下示例演示了如何使用 Java PropertyPermission getActions() 方法来检查权限对象。我们创建了一个 PropertyPermission 对象,然后检查其读取权限。
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 action if(actions.contains("read")) System.out.println("Has permissions on "+path+" for read"); } } }
输出
让我们编译并运行上面的程序,这将产生以下结果:
Has permissions on java.home.usr for read
检查 PropertyPermission 实例的写入访问权限示例
以下示例演示了如何使用 Java PropertyPermission getActions() 方法来检查权限对象。我们创建了一个 PropertyPermission 对象,然后检查其写入权限。
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 write action if(actions.contains("write")) System.out.println("Has permissions on "+path+" for write"); } } }
输出
让我们编译并运行上面的程序,这将产生以下结果:
Has permissions on java.home.usr for write
java_util_propertypermission.htm
广告