import java.io.File;
import java.util.TreeMap;
public class Read {
public static void main(String[] args) {
//output("/usr/local/file");
output("E:/file");
}
public static void output(String dir) {
try {
TreeMap
File file = new File(dir);
File[] files = file.listFiles();
if (0 == files.length) {
return;
}
for (int i = 0; i <= files.length - 1; i++) {
Long modifytimeL = new Long(files[i].lastModified());
tm.put(modifytimeL, files[i]);
}
java.util.Iterator
while(it.hasNext())
{
Long timeKey = it.next();
File tempFile = tm.get(timeKey);
System.out.println(tempFile.getName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
为什么会这样呢?
PS:在Windows环境中上代码可以正常输出0~9的文件,但在Linux环境中却只输出了5个