参考jdk14的手册可知: There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order. 如果你想让它按文件名排序,需要自己实现。我觉得用Arrays.sort(files)应该就可以了,负责你需要改写File.compareTo()的方法实现
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
如果你想让它按文件名排序,需要自己实现。我觉得用Arrays.sort(files)应该就可以了,负责你需要改写File.compareTo()的方法实现
你listFile以后的每个File对象可以取名字的对吧,把他按目录和文件再分到两个两个MAP容器里面,每个FILE对象做值,他们的名字做键,然后按自然排序就可以了,我记得有个容器叫SortedMap吧
因为自然排序就是按照字符串的字母顺序排的,所以用一个支持自然排序的键值对(map)存放String[] File[],顺序他自己就给你排好了哟~
public class TreeMap<K,V>extends AbstractMap<K,V>implements NavigableMap<K,V>, Cloneable, Serializable
基于红黑树(Red-Black tree)的 NavigableMap 实现。该映射根据其键的自然顺序进行排序,或者根据创建映射时提供的 Comparator 进行排序,具体取决于使用的构造方法。
-----------------------------------------------------------------------------------------------------------------------------就用这个容器就好了
在unix下就不行,取出的修改时间全是0(long),有没有人知道原因?