如何使用Java中的Apache Camel从目录中获取特定文件?
我有一个方案,一个目录包含各种名为pattern filehmm的文件,例如:
hh = hhus mm =分钟
dir: file1200.txt file1210.txt File1220.txt 其他File1.txt 其他file2.txt
我需要根据hh:mm找到最新文件,在我的情况下,它将是file1220.txt
I have an scenario, a directory contains various file named pattern filehhmm like:
hh=hours
mm=minutes
dir:
file1200.txt
file1210.txt
file1220.txt
otherfile1.txt
otherfile2.txt
I need to find latest file based on hh:mm, in my case it would be file1220.txt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用自定义比较器(基于时间戳部分)对文件(下降)进行对,并将轮询限制为一个文件。
注意在限制轮询文件的数量之前应用排序(请参阅
eagermaxmessagespollpoll
)Sort your files (descending) using a custom comparator (based on the timestamp part), and limit the polling to one single file.
Take care to apply the sorting BEFORE limiting the number of polled files (see
eagerMaxMessagesPerPoll
)