954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

FileFilter vs. FileNameFilter

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}:)

bhattpratik
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

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.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

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

Respacted Sir,

Thankyou For your early and very helpfull answer.

bhattpratik
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: