NZEC Error : Snape Problem

In the below JAVA program I am getting NZEC error without using try catch statement, but with try catch statement it runs fine . It happens almost always . I am not able to figure out that is this problem of my code or Code Chef java compiler. Please suggest solution .

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
 
class ClassTest 
	{
		public static void main(String args[] ) throws Exception 
		{ try{
			int T=0 ,read;
			 BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); 
			 
			 // No of Test Cases
	        while((read = System.in.read()) != '\n' ) 
	        {  if( read != '\r' )                T = T*10 + read -48 ;	    }  
			
		   
	       while(T --> 0)
	       {   
	    	   int A=0,B=0 ;
	    	    
	             while((read = System.in.read()) != ' ' ) 
	             {  if( read != '\r' && read != '-')                 A = A*10 + read -48  ;	} 
                          	   
                 while((read = System.in.read()) != '\n' && read != -1 ) 
     	         {  if( read != '\r' && read != '-')                 B= B*10 + read -48  ;	}
                
                 int a =Math.max(A,B);
                 int b =Math.min(A,B);
                 
                 float max =(float)Math.sqrt(a*a +b*b); 
                 float min =(float)Math.sqrt((a*a)  - (b*b)); 
                 
                 out.write(min + " ");
     	         out.write(max + "\n");	       	  
           }
		   out.flush();
	       out.close();
	       System.in.close();	    
		}catch(Exception e){}	  	                            
	}
				
}

Are you testing on Windows, try linux, probably problem with '\r' … Also I’m not sure if you can use close(), but while there is try-catch block, there should not be NZEC…

Yeah got it !!! close() was the problem … thanks