Java.util.PropertyPermission.hashCode() 方法


Java.util.PropertyPermission.hashCode() 方法

package com.codingdict;

import java.util.Date;
import java.util.Hashtable;
import java.util.PropertyPermission;

public class PropertyPermissionDemo {
   private static Hashtable<PropertyPermission, Date> validity;

   public static void main(String[] args) {

      // Build property permissions validity collection
      validity = new Hashtable<PropertyPermission, Date>();
      validity.put(new PropertyPermission("java.home.usr", "read"),
      new Date(2012, 12, 31));

      // Get permissions and validity
      checkFilePermissions("java.home.usr");
   }

   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: "+validity.get(permission));
   }
}