// Create a filter GlobFilenameFilter filter = new GlobFilenameFilter( args[0]);
// Find all the files in the folder matching that filter File cwd = new File( "." ); String[] filesFound = cwd.list( filter );
// And PRint them out System.out.println( "Found " + filesFound.length + "files"); for( int i = 0; i < filesFound.length; i ++ ) { System.out.println(" Found file " + filesFound[i] ); } } } 大家可以将这个文件放在自己的IDE里面运行, 并在工作目录里面建3个txt文件:1.txt 2.txt 3.txt