Example usage for java.io FilePermission newPermissionCollection

List of usage examples for java.io FilePermission newPermissionCollection

Introduction

In this page you can find the example usage for java.io FilePermission newPermissionCollection.

Prototype

@Override
public PermissionCollection newPermissionCollection() 

Source Link

Document

Returns a new PermissionCollection object for storing FilePermission objects.

Usage

From source file:Main.java

public static void main(String[] args) throws IOException {

    // create new file permissions
    FilePermission fp = new FilePermission("C://test.txt", "read");

    // create new permission collection
    PermissionCollection pc = fp.newPermissionCollection();

    // add permission to the permission collection
    pc.add(fp);//from  w  w  w  . j a v  a  2 s.  c o m

    if (pc.implies(new FilePermission("C://test.txt", "read"))) {
        System.out.println("Permission for C://test.txt is read");
    }
}