Java 实例 - 在指定目录中查找文件
Java 教程
· 2019-02-11 08:27:12
以下实例演示了在 C 盘中查找以字母 'b' 开头的所有文件:
Main.java 文件
import java.io.*;
class Main {
public static void main(String[] args) {
File dir = new File("C:");
FilenameFilter filter = new FilenameFilter() {
public boolean accept
(File dir, String name) {
return name.startsWith("b");
}
};
String[] children = dir.list(filter);
if (children == null) {
System.out.println("目录不存在或它不是一个目录");
}
else {
for (int i=0; i < children.length; i++) {
String filename = children[i];
System.out.println(filename);
}
}
}
}
以上代码运行输出结果为:
build build.xml
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
Ajax Design Patterns
Michael Mahemoff / O'Reilly Media / 2006-06-29 / USD 44.99
Ajax, or Asynchronous JavaScript and XML, exploded onto the scene in the spring of 2005 and remains the hottest story among web developers. With its rich combination of technologies, Ajax provides a s......一起来看看 《Ajax Design Patterns》 这本书的介绍吧!