2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 80   Methods: 2
NCLOC: 35   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
IoUtil.java 50% 100% 100% 88.9%
coverage coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2001-2003 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * You may obtain a copy of the License at
 9   
  * 
 10   
  *   http://www.apache.org/licenses/LICENSE-2.0
 11   
  * 
 12   
  * Unless required by applicable law or agreed to in writing, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.internal.util;
 21   
 
 22   
 import java.io.BufferedReader;
 23   
 import java.io.IOException;
 24   
 import java.io.InputStream;
 25   
 import java.io.InputStreamReader;
 26   
 
 27   
 /**
 28   
  * Various utility methods for manipulating IO streams.
 29   
  *
 30   
  * @version $Id: IoUtil.java 238991 2004-05-22 11:34:50Z vmassol $
 31   
  */
 32   
 public class IoUtil
 33   
 {
 34   
     /**
 35   
      * @see #getText(InputStream, String)
 36   
      */
 37  9
     public static String getText(InputStream theStream) throws IOException
 38   
     {
 39  9
         return getText(theStream, null);
 40   
     }
 41   
 
 42   
     /**
 43   
      * Read all data in an Input stream and return them as a 
 44   
      * <code>String</code> object.
 45   
      *
 46   
      * @param theStream the input stream from which to read the data
 47   
      * @param theCharsetName the charset name with which to read the data
 48   
      * @return the string representation of the data
 49   
      * @throws IOException if an error occurs during the read of data
 50   
      */
 51  33
     public static String getText(InputStream theStream, String theCharsetName) 
 52   
         throws IOException
 53   
     {
 54  33
         StringBuffer sb = new StringBuffer();
 55   
 
 56  33
         BufferedReader input;
 57  33
         if (theCharsetName == null)
 58   
         {
 59  9
             input = new BufferedReader(new InputStreamReader(theStream));
 60   
         }
 61   
         else
 62   
         {
 63  24
             input = new BufferedReader(
 64   
                new InputStreamReader(theStream, theCharsetName));
 65   
         }
 66   
         
 67  33
         char[] buffer = new char[2048];
 68  33
         int nb;
 69   
 
 70  ?
         while (-1 != (nb = input.read(buffer, 0, 2048)))
 71   
         {
 72  32
             sb.append(buffer, 0, nb);
 73   
         }
 74   
 
 75  33
         input.close();
 76   
 
 77  33
         return sb.toString();
 78   
     }
 79   
 }
 80