简体   繁体   中英

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. 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.

That is not the purpose of Camel to delete files.

You can more easily use Java File API for that. And there is also bash scripts for such use-cases, eg housecleaning.

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.

Then you can route to a log null endpoint

Something ala

from file ? xxxxx
    to log dummy ? log = OFF

But as sad, then just use Java File API code is likely better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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