Home » Java FilePermission Class

Java FilePermission Class

by Online Tutorials Library

Java FilePermission Class

Java FilePermission class contains the permission related to a directory or file. All the permissions are related with path. The path can be of two types:

1) D:\IO\-: It indicates that the permission is associated with all sub directories and files recursively.

2) D:\IO\*: It indicates that the permission is associated with all directory and files within this directory excluding sub directories.


Java FilePermission class declaration

Let’s see the declaration for Java.io.FilePermission class:


Methods of FilePermission class

Method Description
ByteArrayOutputStream() Creates a new byte array output stream with the initial capacity of 32 bytes, though its size increases if necessary.
ByteArrayOutputStream(int size) Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Java FilePermission class methods

Method Description
int hashCode() It is used to return the hash code value of an object.
String getActions() It is used to return the “canonical string representation” of an action.
boolean equals(Object obj) It is used to check the two FilePermission objects for equality.
boolean implies(Permission p) It is used to check the FilePermission object for the specified permission.
PermissionCollection newPermissionCollection() It is used to return the new PermissonCollection object for storing the FilePermission object.

Java FilePermission Example

Let’s see the simple example in which permission of a directory path is granted with read permission and a file of this directory is granted for write permission.

Output

Read, Write permission is granted for the path D:IO Packagejava.txt 
Next TopicJava Writer Class

You may also like