Java IO Tutorial - Java FilePermission.equals(Object obj)








Syntax

FilePermission.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use FilePermission.equals(Object obj) method.

// w w  w.jav a2  s  . c  o m
import java.io.FilePermission;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    FilePermission fp = new FilePermission("C://test.txt", "read");
    FilePermission fp1 = new FilePermission("C://test1.txt", "read");
    FilePermission fp2 = new FilePermission("C://test.txt", "write");
    FilePermission fp3 = new FilePermission("C://test.txt", "read");

    boolean bool = fp.equals(fp1);

    System.out.println(bool);

    bool = fp.equals(fp2);

    System.out.println(bool);

    bool = fp.equals(fp3);
    System.out.print(bool);
  }
}

The code above generates the following result.