0

我收到来自 URL 的响应,并且正在控制台上打印。

回应是Šèô; fREïp\ô .

谁能告诉我如何阅读此回复?

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

这就是我读取响应的方式,输出System.out.println(conn.getContentType()); 是 application/x-protobuffer

4

1 回答 1

2

您提到输出数据的 MIME 类型是application/x-protobuffer. 在这种情况下,您得到的输出可能是一个协议缓冲区。协议缓冲区是一种二进制格式,您得到的响应看起来像垃圾,因为您试图将二进制数据解码为文本。

您可能需要使用 Google 的Protocol Buffers代码来读取这些数据。

于 2011-03-12T12:19:04.900 回答