Read contents of a file containing key value pairs without normal parsing

时光怂恿深爱的人放手 提交于 2019-12-08 08:08:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!