• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Get files based on Pattern Matching Algorithm

 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

My problem is if in a directory structure I have 3 files e.g

ABC_1_1.jpg
ABC_1_2.jpg
ABC_2_1.jpg


Now If I want to know the number of files starting with ABC_1.

How should I do this.

Moderators,

I feel sorry for asking the solution but beleive me I am not doing my homework, If someone provides me code I would be happy but even If someone provide guidence for this flow, I would be really happy.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FileFilter or FilenameFilter
 
Shaan Shar
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Peter Chase:
FileFilter or FilenameFilter



Ok I got the point. I have coded in the following way



Thanks for the help.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bingo!

Regular expressions might be fun, too, if you think your patterns will get much more complex. Or overkill if not. Start here if you haven't used RegEx before.
 
Shaan Shar
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stan James:
Bingo!

Regular expressions might be fun, too, if you think your patterns will get much more complex. Or overkill if not. Start here if you haven't used RegEx before.



Yeah,

But I don't know how to use Regular Expressions.

Could anyone give any example using Regular Expressions. Actually I also want to use regular expression in the code I have listed in my earlier post.

Thanks in advance
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For nearly any Java topic enter "Sun tutorial topic" in Google. That's how I found the Sun Regular Expression Tutorial I linked above.
 
It runs on an internal combustion engine. This ad does not:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic