hashCode(): This method is available in the java.io.File class of Java.
Syntax:
int java.io.FilePermission.hashCode()
This method returns the hash code value for this object.
Parameters: NA
Returns: a hash code value for this object.
Exceptions: NA
Approach
Java
import java.io.FilePermission;public class FilePermissionhashCode {public static void main(String[] args) {String path = "D:\\hello.txt";String actions = "read";FilePermission filePermission =new FilePermission(path, actions);System.out.println(filePermission.hashCode());}}
Output:
-961847279
Some other methods of FilePermission
equals(Object): This method checks two FilePermission objects for equality. Checks that obj is a FilePermission, and has the same pathname and actions as this object.
FilePermission(String, String): This method creates a new FilePermission object with the specified actions.
getActions(): This method returns the "canonical string representation" of the actions.
hashCode(): This method returns the hash code value for this object.
implies(Permission): This method checks if this FilePermission object "implies" the specified permission.
newPermissionCollection(): This method returns a new PermissionCollection object for storing FilePermission objects.
No comments:
Post a Comment