package test; import java.io.File; import java.io.FileFilter; public class TypeFileFilter implements FileFilter{ @Override public boolean accept(File file) { String name = file.getName(); if (name.endsWith(".txt")) { return true; } else { return false; } } }