aspose file tools*
The moose likes I/O and Streams and the fly likes Apply FilenameFilter to only 1 file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Apply FilenameFilter to only 1 file" Watch "Apply FilenameFilter to only 1 file" New topic
Author

Apply FilenameFilter to only 1 file

Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Ok, I've got a problem, I have a function wich can check the file extension of all the files in a dir with FilenameFilter, but now I want to do a much simpler thing, but I don't know how to do it. I want to check the extension of only 1 file, but the problem I find is that the only way I know of invoking the FilenameFilter class is by making a File.list(), and as my File path is the path to a file and not to a dir, this doesn't work. Anyone knows how to do it? Thanks.
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Ok, I did what I should have done before posting, I've taken a look to the code for a second, and I've realized how easy the answer was, Here it is:

I can't call the FilenameFilter class without making a File.list(), but I can create a FilenameFilter object and then invoke it's accept function giving it the pathname to my file as a parameter:



this.ruta is the path to the file I want to check.
I hope this is helpful to someone.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apply FilenameFilter to only 1 file