1 23 package org.hammurapi.inspectors.testcases.fixes; 24 25 import java.io.FileReader ; 26 import java.io.IOException ; 27 import java.io.Reader ; 28 29 import org.hammurapi.inspectors.testcases.HammurapiTestCasesException; 30 31 36 public class ReturnFromFinallyRuleFixTestCase { 37 38 private static org.apache.log4j.Logger logger = 39 org.apache.log4j.Logger.getRootLogger(); 40 41 private static final String FILE_ERROR_TXT = "File error"; 42 43 44 public int getFirstByte(final String fName) 45 throws HammurapiTestCasesException { 46 47 Reader r = null; 48 try { 49 r = new FileReader (fName); 50 int a = r.read(); 51 return a; 52 53 } catch (java.io.FileNotFoundException e) { 54 logger.fatal(FILE_ERROR_TXT, e); 55 throw new HammurapiTestCasesException(e); 56 } catch (IOException e) { 57 logger.fatal(FILE_ERROR_TXT, e); 58 throw new HammurapiTestCasesException(e); 59 } finally { 60 try { 61 r.close(); 62 } catch (IOException e) { 63 logger.fatal(FILE_ERROR_TXT, e); 64 throw new HammurapiTestCasesException(e); 65 } 66 67 69 } 70 } 71 } 72 73 | Popular Tags |