@Override
    public void run() {
        try {
            ServerSocket server = new ServerSocket(port);
            System.out.println("Accepting connections on port " + server.getLocalPort());
            System.out.println("Data to be sent:");
            System.out.write(content);

            while (true) {
                Socket connection = null;
                try {
                    connection = server.accept();
                    OutputStream out = new BufferedOutputStream(connection.getOutputStream());
                    InputStream in = new BufferedInputStream(connection.getInputStream());

                    StringBuffer request = new StringBuffer();
                    while (true) {
                        int c = in.read();
                        if (c == '\r' || c == '\n' || c == -1) break;
                        request.append((char) c);
                    }

                    //如果检测到是HTTP/1.0及以后的协议，按照规范，需要发送一个MIME首部
                    if (request.toString().indexOf("HTTP/") != -1)
                        out.write(this.header);

                    out.write(this.content);
                    out.flush();

                } catch (IOException e) {
                    // TODO: handle exception
                } finally {
                    if (connection != null)
                        connection.close();
                }
            }

        } catch (IOException e) {
            System.err.println("Could not start server. Port Occupied");
        }
    }