Java.io.FilePermission.hashCode() 方法
描述
java.io.FileOutputStream.hashCode() 方法返回此对象的哈希码值。
声明
以下是 java.io.FilePermission.hashCode() 方法的声明 −
public int hashCode()
参数
NA
返回值
该方法返回此对象的哈希码值。
异常
NA
示例
下面的例子展示了 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

