- import java.net.*;
- import java.io.*;
- public class ServerDemo {
- public static void main(String[] args) throws Exception
- {
- ServerSocket ss = new ServerSocket(10077);
- int i = 100;
- while(i-->0)
- {
- Socket s = ss.accept();
- new Thread(new Serv(s)).start();
- }
- ss.close();
- }
- }
- class Serv implements Runnable
- {
- private Socket s;
- public Serv(Socket s)
- {
- this.s = s;
- }
- public void run()
- {
- try{
-
- FileInputStream in = new FileInputStream("D:\\html\\dom\\Table.html");
- int len = 0;
- byte[] buf = new byte[1024];
- PrintWriter out = new PrintWriter(s.getOutputStream(),true);
-
-
- while((len = in.read(buf))!= -1)
- {
- System.out.println(new String(buf,0,len));
- out.print(new String(buf,0,len));
- }
- s.close();
- in.close();
- }
- catch(Exception e)
- {
- new RuntimeException("异常错误");
- }
- }
- }
复制代码
|
|