• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apply FilenameFilter to only 1 file

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
This tiny ad will self destruct in five seconds.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic