Clover coverage report - Maven Clover report
Coverage timestamp: Sun Mar 18 2007 17:43:17 CET
file stats: LOC: 51   Methods: 4
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Read.java 0% 6.2% 25% 8.3%
coverage coverage
 1    package com.agical.rdoc.util;
 2   
 3    import java.io.IOException;
 4    import java.io.InputStream;
 5    import java.io.InputStreamReader;
 6    import java.io.Reader;
 7    import java.io.UnsupportedEncodingException;
 8   
 9    /**
 10    * @author brolund
 11    *
 12    * (c) 2005 Agical AB
 13    */
 14    public class Read {
 15   
 16  1 public static InputStream readAsStream( Class clazz, String fileName ) {
 17  1 return clazz.getResourceAsStream( fileName );
 18    }
 19   
 20  0 public static String read( Class clazz, String fileName ) throws IOException {
 21  0 return read( clazz, fileName, "UTF-8" );
 22    }
 23   
 24  0 public static String read( Class clazz, String fileName, String enc ) throws IOException {
 25  0 InputStream inputStream = null;
 26  0 try {
 27  0 inputStream = readAsStream( clazz, fileName );
 28  0 return readInputStream(enc, inputStream);
 29    } finally {
 30  0 if( inputStream != null ) {
 31  0 try {
 32  0 inputStream.close();
 33    } catch (IOException e) {
 34    // ignore
 35    }
 36    }
 37    }
 38    }
 39   
 40  0 public static String readInputStream(String enc, InputStream inputStream) throws UnsupportedEncodingException, IOException {
 41  0 StringBuffer stringBuffer = new StringBuffer();
 42  0 Reader reader = new InputStreamReader( inputStream, enc );
 43  0 char[] tmp = new char[1024];
 44  0 int read = 0;
 45  0 while( (read = reader.read(tmp)) != -1 ) {
 46  0 stringBuffer.append( tmp, 0, read );
 47    }
 48  0 return stringBuffer.toString();
 49    }
 50   
 51    }