开发者

Response from a URL

开发者 https://www.devze.com 2023-02-16 04:37 出处:网络
I am getting a开发者_如何学编程 response from a URL and I am printing on the console. The response is Šèô;fREïp\\ô­.

I am getting a开发者_如何学编程 response from a URL and I am printing on the console.

The response is Šèô; fREïp\ô­.

Can anyone tell me how to read this response?

BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
   response = response + line;
}

This is how I am reading a response and the output of System.out.println(conn.getContentType()); is application/x-protobuffer


You mention that the MIME type of the output data is application/x-protobuffer. In that case, the output you're getting is probably a protocol buffer. Protocol buffers are a binary format, and the response you've got looks like garbage because you attempted to decode binary data as if it were text.

You may need to use Google's Protocol Buffers code to read this data.

0

精彩评论

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