Here you can find the source of createPathComparator()
private static Comparator<Path> createPathComparator()
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.util.Comparator; public class Main { private static Comparator<Path> createPathComparator() { return new Comparator<Path>() { @Override/*w ww .j a va 2s .co m*/ public int compare(Path p1, Path p2) { String s1 = (p1 != null ? p1.toString() : null); String s2 = (p2 != null ? p2.toString() : null); if (s1 == null) { s1 = ""; } return s1.compareTo(s2 != null ? s2 : ""); } }; } }