import java.io.*; import java.net.*; public class Epp1{ public static void main(String argumendid[]) throws IOException{ ServerSocket ss=new ServerSocket(3001); while(true){ new Epuloim(ss.accept()); } } } class Epuloim extends Thread{ Socket sc; public Epuloim(Socket usc){ sc=usc; start(); } public void run(){ try{ PrintWriter valja=new PrintWriter(sc.getOutputStream(), true); BufferedReader sisse=new BufferedReader( new InputStreamReader(sc.getInputStream())); valja.println("Nimi palun!"); String nimi=sisse.readLine(); System.out.println(nimi); boolean olemas=false; BufferedReader s1=new BufferedReader(new FileReader("nimed.txt")); String rida=s1.readLine(); while(rida!=null){ if(nimi.equals(rida))olemas=true; rida=s1.readLine(); } s1.close(); if (!olemas){ PrintWriter faili=new PrintWriter(new FileWriter("nimed.txt", true)); faili.println(nimi); faili.close(); } sc.close(); }catch(Exception e){ System.out.println("Probleem "+e); } } }