public static String readFromStream(InputStream is){
  InputStreamReader isr;
  try {
    isr=new InputStreamReader(is,"UTF-8");
    BufferedReader br=new BufferedReader(isr);
    StringBuilder sb=new StringBuilder();
    String line;
    while ((line=br.readLine()) != null) {
      sb.append(line);
      sb.append('\n');
    }
    br.close();
    return sb.toString();
  }
 catch (  UnsupportedEncodingException e) {
    return null;
  }
catch (  IOException e) {
    return null;
  }
}

public static String readFromStream ( InputStream is ) { InputStreamReader isr ; try { isr = new InputStreamReader ( is , "UTF-8" ) ; BufferedReader br = new BufferedReader ( isr ) ; StringBuilder sb = new StringBuilder ( ) ; String line ; while ( ( line = br . readLine ( ) ) != null ) { sb . append ( line ) ; sb . append ( '\n' ) ; } br . close ( ) ; return sb . toString ( ) ; } catch ( UnsupportedEncodingException e ) { return null ; } catch ( IOException e ) { return null ; } }
read all data from an input stream . return null if io error .
