1 23 24 package org.hammurapi.inspectors.testcases.violations; 26 27 import java.io.FileInputStream ; 28 import java.io.InputStream ; 29 30 import org.hammurapi.inspectors.testcases.HammurapiTestCasesException; 31 32 37 public class MaxLinesInFileRuleViolationTestCase { 38 39 private static org.apache.log4j.Logger logger = 40 org.apache.log4j.Logger.getRootLogger(); 41 42 private static final String FILE_ERROR_TXT = "File error"; 43 44 45 public int getFirstByte(final String fName) 46 throws HammurapiTestCasesException { 47 48 try { 49 InputStream is = new FileInputStream (fName); 50 return is.read(); 51 52 } catch (Exception e) { 53 logger.fatal(FILE_ERROR_TXT, e); 54 throw new HammurapiTestCasesException(e); 55 } 56 } 57 58 59 public int getSecondByte(final String fName) 60 throws HammurapiTestCasesException { 61 62 try { 63 InputStream is = new FileInputStream (fName); 64 is.read(); 65 return is.read(); 66 67 } catch (Exception e) { 68 logger.fatal(FILE_ERROR_TXT, e); 69 throw new HammurapiTestCasesException(e); 70 } 71 } 72 73 74 public int getThirdByte(final String fName) 75 throws HammurapiTestCasesException { 76 77 try { 78 InputStream is = new FileInputStream (fName); 79 is.read(); 80 is.read(); 81 return is.read(); 82 83 } catch (Exception e) { 84 logger.fatal(FILE_ERROR_TXT, e); 85 throw new HammurapiTestCasesException(e); 86 } 87 } 88 89 90 public int getFourthByte(final String fName) 91 throws HammurapiTestCasesException { 92 93 try { 94 InputStream is = new FileInputStream (fName); 95 is.read(); 96 is.read(); 97 is.read(); 98 return is.read(); 99 100 } catch (Exception e) { 101 logger.fatal(FILE_ERROR_TXT, e); 102 throw new HammurapiTestCasesException(e); 103 } 104 } 105 } 106 108 | Popular Tags |