码迷,mamicode.com
首页 > Web开发 > 详细

http server

时间:2015-02-01 12:01:59      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

package net.datafans.exercise.rockmq.TestJMS;

import java.io.*;

import java.net.*;

public class ServerDemo {

public static void main(String args[]) throws IOException {

ServerSocket ss = new ServerSocket(12345);//端口号12345

while(true) {

Socket socket = ss.accept();

OutputStream out = socket.getOutputStream();

BufferedReader br = new BufferedReader(new FileReader("/Users/apple/Documents/demo/TestJMS/1.html"));

                        out.write("HTTP/1.0 200 \n".getBytes()); 

                        out.write("Content-Type: text/html\n".getBytes()); 

                        out.write("\n".getBytes());

String line=null;

while((line = br.readLine()) != null) {

out.write(line.getBytes());

}

socket.close();

br.close();

out.close();

}

}

 

 

python -m SimpleHTTPServer

sudo nc -kl 80

http server

标签:

原文地址:http://www.cnblogs.com/super-d2/p/4265281.html

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