package cn.david.net.test;
import java.io.*;
import java.net.*;
public class MyBrowser {
/**
* @param args
*/
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
browser();
}
public static void browser() throws IOException{
Socket s = new Socket("192.168.0.100",8080);
PrintWriter out = new PrintWriter(s.getOutputStream(),true);
out.println("GET /MyWeb/testDemo.html HTTP/1.1 ");
out.println("Accept: */* ");
out.println("Host: 192.168.0.100:8080");
out.println("Connection: close ");
out.println(" ");
out.println(" ");
InputStream in = s.getInputStream();
byte[] buf = new byte[1024];
int len = 0;
while((len=in.read(buf))!=-1){
String str = new String(buf,0,len);
System.out.println(str);
}
s.close();
}
}