File path compare
In this chapter you will learn:
Compare two file path
The following methods compare the file paths not the file content.
int compareTo(File pathname)
compares two file lexicographically.boolean equals(Object obj)
tests this abstract pathname for equality with the given object.
import java.io.File;
// j a va2 s. c om
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));//false
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » I/O