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
这篇关于读取包含键值对的文件的内容,无需正常解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:读取包含键值对的文件的内容,无需正常解析
基础教程推荐
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- JPA惰性列表上的流 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
