1 import java.net.*; 2 import java.io.*; 3 public class Server{ 4 public static void main(String args[]) throws Exception{ 5 ServerSocket server = new ServerSocket(9999); 6 while(true){ 7 Socket sock = server.accept(); 8 FileInputStream in = new FileInputStream("f:\javademo\a.html"); 9 OutputStream out = sock.getOutputStream(); 10 int len=0; 11 byte buffer[] =new byte[1024]; 12 while((len=in.read(buffer))>0){ 13 out.write(buffer,0,len); 14 } 15 in.close(); 16 out.close(); 17 sock.close(); 18 } 19 //server.close(); 20 } 21 }