public final class

FilePermission

extends Permission
implements Serializable
java.lang.Object
   ↳ java.security.Permission
     ↳ java.io.FilePermission

Class Overview

A permission for accessing a file or directory. The FilePermission is made up of a pathname and a set of actions which are valid for the pathname.

The File.separatorChar must be used in all pathnames when constructing a FilePermission. The following descriptions will assume the char is /. A pathname that ends in /* includes all the files and directories contained in that directory. If the pathname ends in /-, it includes all the files and directories in that directory recursively. The following pathnames have a special meaning:

  • "*": all files in the current directory;
  • "-": recursively all files and directories in the current directory;
  • "<<ALL FILES>>": any file and directory in the file system.

Summary

Public Constructors
FilePermission(String path, String actions)
Constructs a new FilePermission with the path and actions specified.
Public Methods
boolean equals(Object obj)
Indicates if this file permission is equal to another.
String getActions()
Returns the actions associated with this file permission.
int hashCode()
Calculates the hash code value for this file permission.
boolean implies(Permission p)
Indicates whether the permission p is implied by this file permission.
PermissionCollection newPermissionCollection()
Returns a new PermissionCollection in which to place FilePermission objects.
[Expand]
Inherited Methods
From class java.security.Permission
From class java.lang.Object
From interface java.security.Guard

Public Constructors

public FilePermission (String path, String actions)

Since: API Level 1

Constructs a new FilePermission with the path and actions specified.

Parameters
path the pathname of the file or directory to apply the actions to.
actions the actions for the path. May be any combination of "read", "write", "execute" and "delete".
Throws
IllegalArgumentException if actions is null or an empty string, or if it contains a string other than "read", "write", "execute" and "delete".
NullPointerException if path is null.

Public Methods

public boolean equals (Object obj)

Since: API Level 1

Indicates if this file permission is equal to another. The two are equal if obj is a FilePermission, they have the same path, and they have the same actions.

Parameters
obj the object to check equality with.
Returns
  • true if this file permission is equal to obj, false otherwise.

public String getActions ()

Since: API Level 1

Returns the actions associated with this file permission.

Returns
  • the actions associated with this file permission.

public int hashCode ()

Since: API Level 1

Calculates the hash code value for this file permission.

Returns
  • the hash code value for this file permission.

public boolean implies (Permission p)

Since: API Level 1

Indicates whether the permission p is implied by this file permission. This is the case if p is an instance of FilePermission, if p's actions are a subset of this file permission's actions and if p's path is implied by this file permission's path.

Parameters
p the permission to check.
Returns
  • true if the argument permission is implied by the receiver, and false if it is not.

public PermissionCollection newPermissionCollection ()

Since: API Level 1

Returns a new PermissionCollection in which to place FilePermission objects.

Returns
  • A new PermissionCollection object suitable for storing FilePermission objects.