import java.io.File;
import java.util.Iterator;
import org.omg.CORBA.PUBLIC_MEMBER;
public class txt { public static void main(String[] args) { File file=new File("D:\\apache-tomcat-7.0.40-windows-x86"); String extName =".txt"; getfile(file,extName); } public static void getfile(File f,String extName) { if(f==null) { return; } if(f.isDirectory()) { File tempfile[]=f.listFiles(); if(tempfile!=null) { for (File file : tempfile) { getfile(file,extName); } } }else { String path=f.getPath().toLowerCase(); if(path.endsWith(extName)) { System.out.println(f.getPath()); } } } }