简体   繁体   中英

in java how to get files in a given directory

I want to write a java code, where given a directory name, I should be able to get all the files starting with list (so something like list*) and read each file one by one (linewise), and do some processing .

What classes are available and recommended to read a directory. Is my option is to read all file names by File.list and then pick the ones which start with list..

Thanks

Well, the most central class would be File .

Besides that there are some classes that File 's methods need (like FileFilter etc.)

You can also try and have a look at utility libraries like Apache Commons IO .

您可以按照此处所述使用文件过滤器列出

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM