public static Reader getReader ( final URL url , String encoding ) throws IOException { InputStream stream ; try { stream = AccessController . doPrivileged ( new PrivilegedExceptionAction < InputStream > ( ) { @ Override public InputStream run ( ) throws IOException { InputStream is = null ; if ( url != null ) { URLConnection connection = url . openConnection ( ) ; if ( connection != null ) { // Disable caches to get fresh data for reloading. connection . setUseCaches ( false ) ; is = connection . getInputStream ( ) ; } } return is ; } } ) ; } catch ( PrivilegedActionException e ) { throw ( IOException ) e . getException ( ) ; } Reader reader ; if ( encoding != null ) { reader = new InputStreamReader ( stream , encoding ) ; } else { reader = new InputStreamReader ( stream ) ; } return reader ; }
Returns a Reader for reading the specified url .