2016-11-08 106 views
0

我想读取使用Apache骆驼FTP文件,但我的要求是这样的选择4-5文件周围的所有文件,并处理它们,但我的问题是,我怎么才能选择文件对于特定的日期示例,我想选择今天创建的所有文件,并保留昨天的文件。我想读取FTP文件使用Apache骆驼

如何约会使用Apache的骆驼与过滤

回答

0

您可以实现自定义过滤器,并要求骆驼只处理符合筛选

例如文件我写的代码从FTP挑文件:

public class DateFilter<T> implements GenericFileFilter<T> { 
    public boolean accept(GenericFile<T> file) { 
     Calendar c = Calendar.getInstance(); 
     c.set(Calendar.HOUR_OF_DAY, 0); 
     c.set(Calendar.MINUTE, 0); 
     c.set(Calendar.SECOND, 0); 
     c.set(Calendar.MILLISECOND, 0); 
     long todayInMillis = c.getTimeInMillis(); 
     return file.getLastModified() >= todayInMillis; 
    } 
} 

定义的FileFilter作为豆

<bean id="dateFilter" class="com.something.DateFilter"/> 

使用上面的过滤器在你的路线

from("ftp://[email protected]?password=secret&amp;filter=#dateFilter") 
    .to("somedestination") 

文档here

+0

感谢Vimsha现在工作正常 – Rajeev