简体   繁体   English

如何使用 apache 骆驼从目录中删除文件

[英]How to delete files from a directory using apache camel

I am new to Camel and was exploring ways to delete files from a particular directory using Camel.我是 Camel 的新手,正在探索使用 Camel 从特定目录中删除文件的方法。 I wanted to know about the different ways of deleting files from a directory based on filters like deleting all.txt files or deleting the files which were not modified within 20 days etc.我想了解基于过滤器从目录中删除文件的不同方法,例如删除 all.txt 文件或删除 20 天内未修改的文件等。

That is not the purpose of Camel to delete files.那不是骆驼删除文件的目的。

You can more easily use Java File API for that.为此,您可以更轻松地使用 Java 文件 API。 And there is also bash scripts for such use-cases, eg housecleaning.还有用于此类用例的 bash 脚本,例如大扫除。

But if you want to attempt Camel then the file component can be used as a consumer to consume files from a filter filtered by name pattern, and also you can file by file modification day and therefore compare for age > 20 days etc.但是,如果您想尝试 Camel,那么文件组件可以用作消费者来使用按名称模式过滤的过滤器中的文件,您也可以按文件修改日期归档,因此比较年龄 > 20 天等。

Then you can route to a log null endpoint然后您可以路由到日志 null 端点

Something ala好东西

from file ? xxxxx
    to log dummy ? log = OFF

But as sad, then just use Java File API code is likely better.但遗憾的是,只需使用 Java 文件 API 代码可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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