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








Syntax

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

public boolean equals(Object obj)

Example

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

/* www. jav  a2s . co  m*/
import java.io.File;

public class Main {
  public static void main(String[] args) {

    // create new files
    File f = new File("test.txt");
    File f1 = new File("test1.txt");

    // returns boolean
    boolean bool = f.equals(f1);

    System.out.println("Equal: " + bool);

  }
}

The code above generates the following result.