骆驼:更改流编码 [英] Camel: changing stream encoding

查看:76
本文介绍了骆驼:更改流编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用该路由从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屋!

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