列出目录中的文件或子目录
import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; /**来自 n o w j a v a . c o m**/ public class Main { public static void main(String[] argv) { File dir = new File("directoryName"); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i = 0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; } } /* 时 代 J a v a - nowjava.com 提供 */ FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return !name.startsWith("."); } }; children = dir.list(filter); File[] files = dir.listFiles(); // This filter only returns directories FileFilter fileFilter =