file count of .txt Java [closed]


public class FileCountFilter {

public File[] findFilesInDir(String dirName){
    File dir = new File(dirName);

    return dir.listFiles(new FilenameFilter() { 
             public boolean accept(File dir, String filename)
                  { return filename.toLowerCase().endsWith(".txt"); }
    } );



The Length of File[] returned by findFilesInDir method would be what you are looking for.

Browse More Popular Posts

Leave a Comment