String pullInSource(InputStream in,Charset encoding){
  String script="";
  BufferedReader f=null;
  try {
    StringBuilder sb=new StringBuilder();
    Reader reader=null;
    if (encoding == null)     reader=new InputStreamReader(in);
 else     reader=new InputStreamReader(in,encoding);
    f=new BufferedReader(reader);
    String line;
    while ((line=f.readLine()) != null) {
      sb.append(line);
      sb.append('\n');
    }
    script=sb.toString();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return script;
}

String pullInSource ( InputStream in , Charset encoding ) { String script = "" ; BufferedReader f = null ; try { StringBuilder sb = new StringBuilder ( ) ; Reader reader = null ; if ( encoding == null ) reader = new InputStreamReader ( in ) ; else reader = new InputStreamReader ( in , encoding ) ; f = new BufferedReader ( reader ) ; String line ; while ( ( line = f . readLine ( ) ) != null ) { sb . append ( line ) ; sb . append ( '\n' ) ; } script = sb . toString ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return script ; }
given an input stream containing source file contents , read in each line
