FilePermission 

Introduction

The Java.io.FilePermission class represents access to a file or directory.It consists of a pathname and a set of actions valid for that pathname. Following are the important points about FilePermission −

  • The actions to be granted are passed to the constructor in a string containing a list of one or more comma-separated keywords. The possible keywords are “read”, “write”, “execute”, and “delete”.
  • Code can always read a file from the same directory it’s in (or a subdirectory of that directory); it does not need explicit permission to do so.

Class declaration

Following is the declaration for Java.io.FilePermission class −

public final class FilePermission
   extends Permission
      implements Serializable

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Class constructors

Sr.No.Constructor & Description
1FilePermission(String path, String actions)This creates a new FilePermission object with the specified actions.

Class methods

Sr.No.Method & Description
1boolean equals(Object obj)This method checks two FilePermission objects for equality.
2String getActions()This method returns the “canonical string representation” of the actions.
3int hashCode()This method returns the hash code value for this object.
4boolean implies(Permission p)This method checks if this FilePermission object “implies” the specified permission.
5PermissionCollection newPermissionCollection()This method returns a new PermissionCollection object for storing FilePermission objects.

Methods inherited

This class inherits methods from the following classes −

  • Java.io.Permission
  • Java.io.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *