I use the following code to compare two Paths in Java:
import java.nio.file.Paths;
public class PathTest {
public static void main(String args[]) {
String path1 = "path1\\file1.jpg";
String path2 = "path1/file1.jpg";
System.out.println(Paths.get(path1));
System.out.println(Paths.get(path2));
System.out.println(Paths.get(path1).equals(Paths.get(path2)));
}
}
I do get the following output on my Windows machine:
path1\file1.jpg
path1\file1.jpg
true
And on linux:
path1\file1.jpg
path1/file1.jpg
false
What's going on here?