code: public static String convertStreamToString(InputStream is, String charset) {
  
      	if (is == null) return null;
  
      	StringBuilder sb = new StringBuilder();
          String line;
  
          long linecount = 0;
          long size = 0;
          try {
          	// TODO: Can this be a performance killer if many many lines or is BufferedReader handling that in a good way?
              boolean emptyBuffer = true;
          	BufferedReader reader = new BufferedReader(new InputStreamReader(new BOMStripperInputStream(is), charset));
              while ((line = reader.readLine()) != null) {
              	// Skip adding line break before the first line
              	if (emptyBuffer) {
              		emptyBuffer = false;
              	} else {
                  	sb.append('\n');
                  	size++;
              	}
              	sb.append(line);
              	linecount++;
              	size += line.length();
  
              	if (logger.isTraceEnabled()) {
  	            	if (linecount % 50000 == 0) {
  	    				logger.trace("Lines read: {}, {} characters and counting...", linecount, size);
  	        			printMemUsage();            	
  	            	}
              	}
              }
          } catch (IOException e) {
          	throw new RuntimeException(e);
  		} finally {
          	if (logger.isTraceEnabled()) {
  				logger.trace("Lines read: {}, {} characters", linecount, size);
  				printMemUsage();            	
          	}
  			// Ignore exceptions on call to the close method
              try {if (is != null) is.close();} catch (IOException e) {}
          }
          return sb.toString();
      }
docs: Converts an InputStream to a String.
  
  To convert an InputStream to a String we use the BufferedReader.readLine()
  method. We iterate until the BufferedReader return null which means
  there's no more data to read. Each line will appended to a StringBuilder
  and returned as String.
  
  Closes the InputStream after completion of the processing.
  
  @param is
  @return