只列出文件,不列出子目录,不列出隐藏文件
import java.io.File; import java.io.IOException; public class Main { /*来自 n o w j a v a . c o m*/ public static void main(String[] arg) throws IOException { String path = "c:/test1"; File dir = new File(path); if (dir.isDirectory()) { File[] files = dir.listFiles(); for (File f : files) { if (f.isFile() && !f.isHidden()) System.out.println(f.getName()); } } } }