我读从一个网站源通过在Java中建立一个合法的连接,就像这样:HTTP协议中的这些奇怪的线是什么?
final Socket sock = new Socket(hostname, 80);
PrintWriter writer = new PrintWriter(sock.getOutputStream(), true);
writer.println("GET /path HTTP/1.1");
writer.println("Host: " + hostname);
writer.println();
//...
while (!sock.isClosed() && (line = reader.readLine()) != null) {
System.out.println(line);
}
和它的作品不错,但也有一些怪异的线路输出,当我浏览其中不存在该网站与 - 说 - 火狐。
问题是某些源代码行被一些随机的不同信息中断,我不知道为什么我会得到那样的信息来毁掉我的源代码。
<div clas
16d0
s="span5">
或
<td style="text-align:c
2000
enter; vertical-align:middle">information</td>
这是什么,如何解决?
分块转码。您可以通过使用HTTP客户端库或自己正确实施HTTP来解决此问题。 – CodeCaster
[为什么HTTP响应主体在开头包含“2fb”?](http://stackoverflow.com/questions/14955994/why-does-the-http-response-body-contain-2fb-at - 开始) – CodeCaster