0

I am writing and image processing program in Java and need to have the program process each image file in a given folder that have the name "image_*.jpg" where the * is a unique string for each image (i.e. image_AAA000.jpg, image_AAA001.jpg, etc.) but I need it to ignore files that don't match that example. How can I do this?

cteeters
  • 49
  • 1
  • 7
  • by *reading* you mean list the files?? and by *ignore files that don't match that example* you mean the pattern in the name??? – ΦXocę 웃 Пepeúpa ツ Mar 01 '16 at 20:40
  • I guess a better word would be "process" rather than "read." I need to take each image, do some processing with this, then move on to the next. For the second part of you question, yes, ignore ones that don't match that patter. – cteeters Mar 01 '16 at 20:42
  • That other question had my answer. Thanks all! – cteeters Mar 01 '16 at 21:09

1 Answers1

0

You can generate a new File from the folder, then use listFiles to get an array of all files in the folder. Then you can iterate over them, including those which match your condition.

For that you can use a regular expression or startsWith or endsWith of the String class.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142