All pastes #960153 Raw Edit

Untitled

public text v1 · immutable
#960153 ·published 2008-03-27 22:19 UTC
rendered paste body
 public void run()
    {
        
        InputStream in=null;
        OutputStream out=null;
        Scanner scan;
        PrintWriter pw;
        
        try
        {
            in = s.getInputStream();
            out = s.getOutputStream();
        }
        catch (IOException ex)
        {
            printErrorStreams();
        }
        
        scan = new Scanner(in);
        pw = new PrintWriter(out);
        
        while(s.isConnected())  //prepei na baloyme kai allo enan elegxo gia 1-2 minutes na testarei an eiani online
        {
            
            try
            {
                String answer = Protocol.getAnswer(scan.nextLine());
                
                if(answer.equals("Bye"))
                {
                    pw.println(answer);
                    pw.flush();
                    try
                    {
                        s.close();
                    }
                    catch (IOException ex)
                    {
                        ex.printStackTrace();
                    }
                    // try
                    // {
                    //  in.close();
                    //  out.close();
                    // pw.close();
                    //  s.close();
                    
                    // Thread.interrupted();
                    //  }
                    //  catch (IOException ex)
                    //  {
                    //      ex.printStackTrace();
                    //  }
                }
                pw.println(answer);
                pw.flush();
            }
            catch(Exception e)
            {
                try
                {
                    s.close();
                } catch (IOException ex)
                {
                    ex.printStackTrace();
                }
                Thread.interrupted();
                System.out.println("THIS IS PRINTING FOR EVER");
            }
            
        }
        
    }