Hello!

I want to know exactly What Is Difference Between The FileFilter and FileNameFilter in java.io.*;

Do they both work the same ?

Please answer .......

-> {Pratik Bhatt}:)

The FilenameFilter is used to filter out files in visual components (e.g. when you navigate to a folder, only *.java files would be seen) and in cases where you need to return file names which satisfy a given criteria. Basically for filtering needs based on "file names", FilenameFilter is used.

FileFilter on the other hand deals with "File" objects i.e. filtering based on a given File attributes like; is the file hidden, is it read only; something which a file name can't give you.

Of course, it's pretty trivial to create a File object based on its name and parent directory so I guess these "two" filters are more of convenient wrappers over the same concept but slightly different use cases.

commented: It's very helpfull +0

TO ~s.o.s~
Super Moderator
Featured Poster
Reputation Points: 2812
Solved Threads: 646

Respacted Sir,

Thankyou For your early and very helpfull answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.