简单的Java Web服务器

 import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket; public class Server { /**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
ServerSocket server = new ServerSocket(9999);
Socket sock = server.accept();
FileInputStream in = new FileInputStream("c:\\a\\1.html");
OutputStream out = sock.getOutputStream();
int len = 0;
byte buffer[] = new byte[1024];
while((len = in.read(buffer)) > 0){
out.write(buffer, 0, len);
}
in.close();
out.close();
sock.close();
server.close();
} }
上一篇:Direct2D开发:绘制网格


下一篇:ASP.NET配置Ueditor编辑器上传图片路径