You've already accepted the answer, but I'll add this anyway, just point out that there is an easier way (assuming you're talking about normal Java property files).
You really don't need to do any sorting, linear comparison, etc. on its own, because equals () in java.util.Properties was implemented wisely and does what you would expect. In other words, β know and use libraries, β as Joshua Bloch would say. :-)
Here is an example. This p1.properties file:
a = 1 b = 2
and p2.properties :
b = 2 a = 1
... you can just read them and compare them with equals ():
Properties props1 = new Properties(); props1.load(new FileReader("p1.properties")); Properties props2 = new Properties(); props2.load(new FileReader("p2.properties")); System.out.println(props1.equals(props2));
Jonik source share