public class TestHttp { public static void main(String[] args) throws Exception { Socket s = new Socket("127.0.0.1",8080); PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream())); pw.println("GET / HTTP/1.1"); pw.println("Host:localhost"); pw.println("Content_Type:text/html"); pw.println();//打印空行 pw.flush();