Trying to read from a URL(in Java) produces gibberish on certain occaisions

后端 未结 4 853
清歌不尽
清歌不尽 2021-01-23 07:43

I\'m trying to read from a URL, and then print the result.

BufferedReader in = new BufferedReader(
     new InputStreamReader(new URL(\"http://somesite.com/\").o         


        
4条回答
  •  自闭症患者
    2021-01-23 07:56

    You're probably running into a character encoding issue.

    There should be an HTTP header like the following in the response:

    Content-Type: text/html; charset=UTF-8
    

提交回复
热议问题