http server

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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。