protected Object evaluate ( InputStream inStrm , String scriptName ) { InputStreamReader streamReader = new InputStreamReader ( inStrm , StandardCharsets . UTF_8 ) ; BufferedReader br = new BufferedReader ( streamReader ) ; StringBuilder sb = new StringBuilder ( ) ; String line ; try { while ( ( line = br . readLine ( ) ) != null ) { sb . append ( line ) . append ( "\n" ) ; } } catch ( IOException e ) { throw new RuntimeException ( "error while reading javascript from stream" , e ) ; } String script = sb . toString ( ) ; return evaluate ( script , scriptName ) ; }
Reads and evaluates the code at the passed input stream . The stream is read to its end but is not closed .