需求是每隔一段时间需要遍历一个文件夹下的某种文件类型,
并对每个文件进行相关操作,
但是用DirectoryStream有如下问题:
While DirectoryStream extends Iterable, it is not a general-purpose Iterable as it supports only a single Iterator; invoking the iterator method to obtain a second or subsequent iterator throws IllegalStateException.
ps:官网API
只能获取一次迭代器,
有办法用NIO的方式来遍历文件吗?
现在我用的是File listFiles的方法来遍历。
谢谢!
并对每个文件进行相关操作,
但是用DirectoryStream有如下问题:
While DirectoryStream extends Iterable, it is not a general-purpose Iterable as it supports only a single Iterator; invoking the iterator method to obtain a second or subsequent iterator throws IllegalStateException.
ps:官网API
只能获取一次迭代器,
有办法用NIO的方式来遍历文件吗?
现在我用的是File listFiles的方法来遍历。
谢谢!