开发者

BufferedReader automatic encoding type

开发者 https://www.devze.com 2023-03-22 15:52 出处:网络
I am using BufferedReader to get data fro ma url. URL url = new URL(\"http://\"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), \"windows-1251\"));

I am using BufferedReader to get data fro ma url.

 URL url = new URL("http://");
 BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), "windows-1251"));

On some url's encoding is windows-125开发者_开发知识库1 (cyrilyc) so i specified that in the reader. But on some ones, enconding is different, e.g KOI8-R Any way to get the data from both sources without using naother reader? I really can use only one here.


No, the BufferedReader cannot examine the Content-Enconding header. You have to supply that. Or use a library for encoding recognition/detection.

0

精彩评论

暂无评论...
验证码 换一张
取 消