赞
踩
import java.io.*;
import java.net.*;
public class MyWebServer
{
public static void main(String []args) throws Exception{
ServerSocket ss=new ServerSocket(80);
Socket s=ss.accept();
System.out.println("在 80上等待连接...");
OutputStream os=s.getOutputStream();
BufferedReader br=new BufferedReader(new FileReader("d:\\hello.html"));
String buf="";
while((buf=br.readLine())!=null){
os.write(buf.getBytes());
}
//关闭流
br.close();
os.close();
s.close();
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。