开发者

in java how to get files in a given directory

开发者 https://www.devze.com 2023-04-09 19:08 出处:网络
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 proc

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 recommende开发者_开发问答d 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.


You can list using a file filter as described here

0

精彩评论

暂无评论...
验证码 换一张
取 消