码迷,mamicode.com
首页 > 其他好文 > 详细

网络编程(自定义图形界面浏览器-Tomcat服务端). 模拟IE 的请求

时间:2016-01-22 13:44:15      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

package netTest;
import java.io.*;
import java.net.*;
public class IE {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("127.0.0.1",8080);
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        out.println("GET /myweb/demo.html HTTP/1.1");
        out.println("Accept: */*");
        out.println("Host: 127.0.0.1:11188");
        out.println("Connection: keep-Alive");
        out.println();
        out.println();
        BufferedReader bufr = new BufferedReader(
                new InputStreamReader(s.getInputStream()));
        String line = null;
        while((line = bufr.readLine())!=null){
            System.out.println(line);
        }
    }
    
}
package netTest;
import java.io.*;
import java.net.*;
public class IE {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("127.0.0.1",8080);
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        out.println("GET /myweb/demo.html HTTP/1.1");
        out.println("Accept: */*");
        out.println("Host: 127.0.0.1:11188");
        out.println("Connection: keep-Alive");
        out.println();
        out.println();
        BufferedReader bufr = new BufferedReader(
                new InputStreamReader(s.getInputStream()));
        String line = null;
        while((line = bufr.readLine())!=null){
            System.out.println(line);
        }
    }
    
}

 

网络编程(自定义图形界面浏览器-Tomcat服务端). 模拟IE 的请求

标签:

原文地址:http://www.cnblogs.com/yangyongqian/p/5150460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!