日期:2014-05-20 浏览次数:20772 次
package cn.dzr.uploadpic;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
public class MyBrowser
{
public static void main(String[] args) throws IOException, IOException
{
Socket socket = new Socket(InetAddress.getLocalHost(),8080);
PrintWriter pw = new PrintWriter(socket.getOutputStream());
pw.println("GET /myweb/1.html HTTP/1.1");
pw.println("Accept : */*");
pw.println("Host: 0.0.0.0:8080");
pw.println("Connection : close");
pw.println();
pw.println();
InputStream in = socket.getInputStream();
byte[] buff = new byte[1024];
int len = in.read(buff);
String str = new String(buff,0,len);
System.out.println(str);
socket.close();
}
}