骆驼:改变流编码 [英] Camel: changing stream encoding
本文介绍了骆驼:改变流编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用该路由从 http 接收数据流:
I'm receiving data stream from http with that route:
from("direct:foo").
to("http://foo.com/bar.html").
to("file:///tmp/bar.html")
HTTP 流带有 Windows-1251
编码.我想即时重新编码为 UTF-8
然后存储到文件中.
HTTP stream comes with Windows-1251
encoding. I'd like to re-code to UTF-8
on the fly and then store to file.
如何使用标准的 camel
方式做到这一点?
How to do that using standard camel
way?
推荐答案
请查看 .convertBodyTo()
- 特别是 charset
参数.
Please have a look at .convertBodyTo()
- in particular the charset
argument.
from("direct:foo").
to("http://foo.com/bar.html").
convertBodyTo(String.class, "UTF-8")
to("file:///tmp/bar.html")
参考:http://camel.apache.org/convertbodyto.html
这篇关于骆驼:改变流编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文