public static String streamToString(final InputStream stream) throws IOException {
  if (stream == null) {
    throw new NullPointerException("null stream given");
  }
  final StringBuilder out=new StringBuilder();
  final byte[] b=FileUtils.makeByteBuffer();
  int len=stream.read(b);
  final int eof=-1;
  while (len != eof) {
    for (int i=0; i < len; i++) {
      out.append((char)b[i]);
    }
    len=stream.read(b);
  }
  return out.toString();
}

public static String streamToString ( final InputStream stream ) throws IOException { if ( stream == null ) { throw new NullPointerException ( "null stream given" ) ; } final StringBuilder out = new StringBuilder ( ) ; final byte [ ] b = FileUtils . makeByteBuffer ( ) ; int len = stream . read ( b ) ; final int eof = - 1 ; while ( len != eof ) { for ( int i = 0 ; i < len ; i ++ ) { out . append ( ( char ) b [ i ] ) ; } len = stream . read ( b ) ; } return out . toString ( ) ; }
gets the contents of the stream as a string .
