读取包含键值对的文件的内容,无需正常解析 [英] Read contents of a file containing key value pairs without normal parsing

查看:19
本文介绍了读取包含键值对的文件的内容,无需正常解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的方案是从文件端点读取文件,该文件仅包含键值 paris,如属性文件,并根据键从中获取一些数据.

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 .

知道如何使用自定义 bean 或 java 组件来完成它们.

Any idea how to do them other that using a custom bean or java component.

我想知道这在 Mule 或 Camel 中是否可行.

I would like to know if this is possible any way in Mule or Camel.

提前致谢.

推荐答案

如果你想使用 Camel 路由来获取文件,那么像这样

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]}")

然后我们需要一个来自 java.io.File -> java.util.Properties 的类型转换器.我们可以直接将其添加到 camel-core 中.

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.

我记录了一张在 Camel 中添加该类型转换器的票:https://issues.apache.org/jira/browse/CAMEL-7312

I logged a ticket to add that type converter out of the box in Camel: https://issues.apache.org/jira/browse/CAMEL-7312

这篇关于读取包含键值对的文件的内容,无需正常解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆