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.
精彩评论