a have a directory with 100 text files , there are for example 1.txt,2.txt,3.txt,.....100.txt, how to find files with specific names in these directory?for example how can I find 1.txt,2.txt,8.txt in these directory?I want to put these specific names in a Arraylist to search in a directory, Can you help me to fix these problem?
Asked
Active
Viewed 64 times
0
-
Take a look at this [link](http://stackoverflow.com/questions/13216432/java-searching-file-name-from-the-one-folder) – Abdelhak Nov 27 '15 at 20:32
-
Duplicate shows you where you should put your filter, but if you are still struggling with how to select only files with structure `oneOrMoreNumber.txt` you could use `return name.matches("\\d+\\.txt");` – Pshemo Nov 27 '15 at 20:43
-
The answer that I found is this : public boolean accept(File directory, String fileName) {return (fileName.endsWith(this.fileExtension)); } but this is not usefull for me because all of my files end with txt, and I want to filter by name..and when I want to print fileName or change it to ArrayList there are some errors.. – avishan sharafi Nov 29 '15 at 17:16