我试图使用Socket获取网页并获取请求,但我一直收到相同的错误 - 错误的请求,对于我尝试使用它的任何网站或网页。
Socket s = new Socket("horstmann.com", 80);
InputStream in = s.getInputStream();
OutputStream out = s.getOutputStream();
Scanner reader = new Scanner(in);
PrintWriter writer = new PrintWriter(out, false);
String command = "GET / HTTP/1.0\n\n";
//System.out.print(command);
writer.print(command);
writer.flush();
while (reader.hasNextLine()) {
System.out.println(reader.nextLine());
}
s.close();
答案 0 :(得分:1)
试试这个:
.vimrc