文件过滤器
public static void main(String[] args) throws IOException { method_6(); } public static void method_6() { File file=new File("c:\\"); String[] names=file.list(new FilenameFliter_by());//得到文件目录 for(String name:names) { sop(name); } }
import java.io.File; import java.io.FilenameFilter; public class FilenameFliter_by implements FilenameFilter { @Override public boolean accept(File dir, String name) { return name.endsWith(".java"); } }