问题
My scenario is to read a file from a file endpoint which contains only key value paris like a property file and take a few data from it based on the key .
Any idea how to do them other that using a custom bean or java component.
I would like to know if this is possible any way in Mule or Camel.
Thanks in advance.
回答1:
If you want to use a Camel route, to pickup files, then something like this
from("file:inbox")
.convertBodyTo(Properties.class)
.log("The foo value is {${body[foo]}")
.log("The bar value is {${body[bar]}")
What we then need is a type converter from java.io.File -> java.util.Properties. Which we could add to camel-core out of the box.
I logged a ticket to add that type converter out of the box in Camel: https://issues.apache.org/jira/browse/CAMEL-7312
回答2:
I think to this problem explained, the very easy solution is to use java.util.Properties class. Load the file using Properties class which maintains key value pair only.
来源:https://stackoverflow.com/questions/22523637/read-contents-of-a-file-containing-key-value-pairs-without-normal-parsing