I am studying Java and I am not really sure the way to searching file. I would like to build the function which returning file names ( the files name should begin with star
and end with .txt
)
For example, in the folder we have Java source file with some file. For example, files:
- 1.txt
- 2.txt
- 4.txt
- start.txt
- star.txt
- onstart.txt
- starton.txt
- myjava.java
Then I would like to get the start.txt
, star.txt
& starton.txt
I was looking for the FilenameFilter
but I wasn't able to find to good way to find file. Does any one know the way to find files?
File#getName() should return a
String`, then use:Probably the easiest way is to simple use
File#listFiles(FileFilter)
, something like