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?

3
  • by reading you mean list the files?? and by ignore files that don't match that example you mean the pattern in the name??? Commented Mar 1, 2016 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. Commented Mar 1, 2016 at 20:42
  • That other question had my answer. Thanks all! Commented Mar 1, 2016 at 21:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.