全屏
Java Java File.list()方法具有以下语法。
public String [] list()
示例
在下面的代码显示如何使用File.list()方法。
import java.io.File;
public class Main {
public static void main(String[] args) {
// create new file
File f = new File("c:/Python3");
// array of files and directory
String[] paths = f.list();
// for each name in the path array
for (String path : paths) {
System.out.println(path);
}
}
}
上面的代码生成以下结果。
DLLs
Doc
include
Lib
libs
LICENSE.txt
NEWS.txt
python.exe
python3.dll
python35.dll
pythonw.exe
README.txt
Scripts
tcl
Tools
vcruntime140.dll
worksp
分享到:
0评论