Java.util.PropertyPermission.equals()の使い方

Javaコード
package Permission;

import java.util.PropertyPermission;

public class PermissionEqual {
private static PropertyPermission permission;

public static void main(String[] args) {
// Build property permissions collection
permission = new PropertyPermission(“java.changfa.kdf", “read");

// Check file read permissions
checkFileReadPermissions(“java.changfa.kdf");
// Check file write permissions
checkFileWritePermissions(“java.changfa.kdf");
}

private static void checkFileReadPermissions(String path) {
// Check permissions are equal
if(permission.equals(new PropertyPermission(path, “read"))) {
System.out.println(“Has permissions on “+path+" 読込み権限");
}
}
private static void checkFileWritePermissions(String path) {
// Check permissions are equal
if(permission.equals(new PropertyPermission(path, “write"))) {
System.out.println(“Has permissions on “+path+"書込み権限");
}
}
}

実行結果
Has permissions on java.changfa.kdf 読込み権限

Java

Posted by arkgame