Java.io.FilePermission.hashCode() 方法



描述

java.io.FileOutputStream.hashCode() 方法返回此对象的哈希码值。

声明

以下是 java.io.FilePermission.hashCode() 方法的声明:

public int hashCode()

参数

返回值

此方法返回此对象的哈希码值。

异常

示例

以下示例演示了 java.io.FilePermission.hashCode() 方法的用法。

package com.tutorialspoint;

import java.io.FilePermission;
import java.io.IOException;

public class FilePermissionDemo {
   public static void main(String[] args) throws IOException {
      FilePermission fp = null;
      
      try {
         // create new file permissions
         fp = new FilePermission("C://test.txt", "read");
         
         // the hash code value
         int hash = fp.hashCode();
         
         // prints
         System.out.print("Hash Code: "+hash);
         
      } catch(Exception ex) {
         // if an error occurs
         ex.printStackTrace();
      }
   }
}

让我们编译并运行以上程序,这将产生以下结果:

Hash Code: 0
java_io_filepermission.htm
广告

© . All rights reserved.