equals(Object): This method is available in the java.io.FilePermission class of Java.
Syntax:
boolean java.io.FilePermission.equals(Object obj)
This method takes one argument. This method checks two FilePermission objects for equality. Checks that obj is a FilePermission, and has the same pathname and actions as this object.
Parameters: One parameter is required for this method.
obj: the object we are testing for equality with this object.
Returns: true if obj is a FilePermission, and has the same pathname and actions as this FilePermission object, false otherwise.
Exceptions: NA
Approach
Java
import java.io.FilePermission;public class FilePermissionequals {public static void main(String[] args) {String path = "D:\\hello.txt";String actions = "read";FilePermission filePermission =new FilePermission(path, actions);System.out.println(filePermission.equals(filePermission));}}
Output:
true
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