FilePermission.implies(Permission p) has the following syntax.
public boolean implies(Permission p)
In the following code shows how to use FilePermission.implies(Permission p) method.
import java.io.FilePermission; import java.io.IOException; /*w w w .j ava 2s. co m*/ public class Main { public static void main(String[] args) throws IOException { // create new file permissions FilePermission fp = new FilePermission("C://test.txt", "read"); FilePermission fp1 = new FilePermission("C://test.txt", "write"); FilePermission fp2 = new FilePermission("C://test1.txt", "read"); FilePermission fp3 = new FilePermission("C://test.txt", "read"); // tests if implied by this object boolean bool = fp.implies(fp1); // print System.out.println(bool); bool = fp.implies(fp2); System.out.println(bool); bool = fp.implies(fp3); System.out.print(bool); } }
The code above generates the following result.