Java listFiles().length return 只有文件数还是文件+文件夹数

Does Java listFiles().length return only files number or files+folders number

我有一个简单的问题: Java listFiles().length 是否会 return 仅调用它的文件夹的文件编号或文件+文件夹编号? Java 文档中没有明确说明,我需要知道这一点。

它returns既是文件又是目录。您可以使用 isFileisDirectory 方法检查它是目录还是文件。

这是在 listFiles 方法的文档中写的

Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

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.

因此return两者都