How to split a file into lines in Camel, but process the first line differently

I split the file into lines using a tokenizer:

.split().tokenize("\n", 1) 

However, some of the files I need to process will contain a header line, which should be handled differently with regular lines. Is there an easy way to read the first line, the process, and then split the remaining lines?

+6
source share
1 answer

You can do something like this. He will use a content-based EIP router, and then various routines for processing.

 from(A) .split().tokenize("\n",1) .choice() .when(simple("${property.CamelSplitIndex} > 0")) .to("direct:processLine") .otherwise() .to("direct:processHeader"); from("direct:processLine") .bean(processLineBean) .to(B); from("direct:processHeader") .bean(processHeaderBean) .to(B); 
+9
source

All Articles