I want to handle files of same type.For example if am dealing with txt files means i hav to read all the text files once and i should also find a certain keyword(similar keyword) which should exists in all those files.

Anyone suggest how to do that.

if you can read one file you can read them all...

Tats was great answer i didnt expect. How to take list of files from the folder

File f1 = new File("E:\\backup_javaprog\\New Folder");
FilenameFilter f2= new OnlyExt("text");
String s[]=f1.list(f2);

Was it correct ???

Use an array list, and the file api for java. Then read all those files with .txt extensions into the arrayList and away you go.

File file = new File(directory);
if (!file.isFile) {
    FilenameFilter filter = .... // that's for you to figure out
    String[] files = file.list(filter);
    ... // now do something with those filenames (which may be directorynames).
commented: Perfect example +5