File[] files = file.listFiles(); List fileList = Arrays.asList(files); Collections.sort(fileList, new Comparator<File>() { @Override public int compare(File o1, File o2) { if (o1.isDirectory() && o2.isFile()) return -1; if (o1.isFile() && o2.isDirectory()) return 1; return o1.getName().compareTo(o2.getName()); } });
JAVA实现返回0001,0002,0003格式数字 参考: https://www.cnblogs.com/pxblog/p/14715545.html