File root[]=File.listFiles();
这句话怎么解释,api说的没有理解,希望高手指教,
具体说一下listFile的用法
------解决方案--------------------
简单翻译了一下,不知道翻得对不
------------------------------------------
列出当前文件(夹)下的文件或目录
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
如果当前路径不是文件夹,就返回null. 否则返回其下的所有文件和目录。当前文件夹和父文件夹不包括在内。(就是说不包含.和..)
子文件或文件夹的抽象名字(用getAbsolutePath 得到的路径)是根据当前目录构造出来的,如果当前目录是用绝对路径造出来的,那子文件或目录也是绝对路径,反之亦然。
If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.
以外,不保证list里的顺序。并不保证按字母顺序排列
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.
------解决方案--------------------
看来都不看源码的,
看源码比看这么一堆文字容易多了。
------解决方案--------------------
看下JDK文档,简单写个例子就知道了!