public static String copyToString(InputStream in,Charset charset) throws IOException {
  Assert.notNull(in,"No InputStream specified");
  StringBuilder out=new StringBuilder();
  InputStreamReader reader=new InputStreamReader(in,charset);
  char[] buffer=new char[BUFFER_SIZE];
  int bytesRead=-1;
  while ((bytesRead=reader.read(buffer)) != -1) {
    out.append(buffer,0,bytesRead);
  }
  return out.toString();
}

public static String copyToString ( InputStream in , Charset charset ) throws IOException { Assert . notNull ( in , "No InputStream specified" ) ; StringBuilder out = new StringBuilder ( ) ; InputStreamReader reader = new InputStreamReader ( in , charset ) ; char [ ] buffer = new char [ BUFFER_SIZE ] ; int bytesRead = - 1 ; while ( ( bytesRead = reader . read ( buffer ) ) != - 1 ) { out . append ( buffer , 0 , bytesRead ) ; } return out . toString ( ) ; }
copy the contents of the given inputstream into a string . leaves the stream open when done .
