Compare two file path

ReturnMethodSummary
intcompareTo(File pathname)Compares two abstract pathnames lexicographically.
booleanequals(Object obj)Tests this abstract pathname for equality with the given object.

import java.io.File;

public class Main {

  public static void main(String[] args) {

    File aFile = new File("c:/aFolder");
    File bFile = new File("c:/bFolder");
    
    System.out.println(aFile.equals(bFile));

  }
}

The output:


false
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.