Read contents of a file containing key value pairs without normal parsing(读取包含键值对的文件的内容,无需正常解析)
问题描述
我的方案是从文件端点读取文件,该文件仅包含键值 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
这篇关于读取包含键值对的文件的内容,无需正常解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:读取包含键值对的文件的内容,无需正常解析


基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01