Here you can find the source of getFiles(String path)
public static File[] getFiles(String path)
//package com.java2s; import java.io.File; import java.util.Arrays; import java.util.Comparator; public class Main { public static File[] getFiles(String path) { File file = new File(path); // get the folder list File[] array = file.listFiles(); Arrays.sort(array, new Comparator<File>() { @Override/*from w ww . j a va 2s . c o m*/ public int compare(File file, File newFile) { if (file.lastModified() < newFile.lastModified()) { return 1; } else if (file.lastModified() == newFile.lastModified()) { return 0; } else { return -1; } } }); return array; } }