Using FilenameFilter to filter files list

FileDemo6.java

import java.io.*; class FileDemo1{ public static void main(String ar[])throws IOException { File f=new File("H:/"); MyFilter filter=new MyFilter(); String s[]=f.list(filter); for(String s1:s){ System.out.println(s1); } } } class MyFilter implements FilenameFilter { public boolean accept(File d,String n) { return n.endsWith(".java"); } }

No comments:

Popular Posts