Is it possible to use a regular expression to get filenames for files matching a given pattern in a directory without having to manually loop through all the files.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
File.listFiles(FileFilter):EDIT
So, to match files that look like:
TXT-20100505-XXXX.trxwhereXXXXcan be any four successive digits, do something like this:EDIT
Starting with Java8 the complete ‘return’-part can be written with a lamda-statement: