java - How to check if a file exists in Apache Camel? -


i have next code:

package camelinaction;  import org.apache.camel.camelcontext; import org.apache.camel.builder.routebuilder; import org.apache.camel.impl.defaultcamelcontext;   public class makenotabenefile {      public static void main(string args[]) throws exception {         // create camelcontext         camelcontext context = new defaultcamelcontext();          // add our route camelcontext         context.addroutes(new routebuilder() {             public void configure() {                  from("quartz://report?cron=0/2+*+*+*+*+?")                  .setbody().simple("\n")                  .to("file:/c:/users/mishin/documents/work_line/?filename=${date:now:ddmmyyyy}/${date:now:ddmmyyyy}_nb.txt");             }         });          // start route , let work         context.start();         thread.sleep(1000);          // stop camelcontext         context.stop();     } } 

i have code creates directory , file current date camel makenotabenefile.java

my question how can check if file exists? because current code overwrites old file , lost notes.

please see fileexist option camel file component under "producer" options in camel file2 documentation.

i believe &fileexist=append (or fail) might you.

also if camel managed rename file got overwritten (documentation says camel 2.11.1 , has behaviour).

alternatively if wanted build logical if in camel route, build bean containing code this: return new file(filename).exists();


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -