「Java」Java.util.PropertyPermission.hashCode() の使い方

投稿者: | 2017年6月17日

Javaコード
package com.changta.tun;
import java.util.Date;
import java.util.Hashtable;
import java.util.PropertyPermission;

public class HashCodeDemo {
private static Hashtable<PropertyPermission, Date> cft;
@SuppressWarnings(“deprecation”)
public static void main(String[] args) {
// Build property permissions cft collection
cft = new Hashtable<PropertyPermission, Date>();
cft.put(new PropertyPermission(“java.home.chang”, “read”),
new Date(2016, 10, 12));

// Get permissions and cft
checkFilePermissions(“java.home.chang”);
}

private static void checkFilePermissions(String path) {
// Hashcode is calculated by name
PropertyPermission permission = new PropertyPermission(path, “read”);
System.out.println(“Has permissions on “+path+
” for read, Till: “+cft.get(permission));
}

}

実行結果
Has permissions on java.home.chang for read, Till: Sun Nov 12 00:00:00 JST 3916

カテゴリー: Java