public static InputStream getUrlAsStream ( URL url , String acceptValue ) throws IOException { HttpURLConnection connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setRequestMethod ( "GET" ) ; if ( acceptValue != null && ! acceptValue . trim ( ) . isEmpty ( ) ) { connection . setRequestProperty ( "Accept" , acceptValue ) ; } final int responseCode = connection . getResponseCode ( ) ; if ( responseCode == HttpURLConnection . HTTP_OK ) { return connection . getInputStream ( ) ; } else { if ( isEventEnabled ( tc ) ) { Tr . event ( tc , "Did not find resource at " + url + ". ResponseCode: " + responseCode ) ; } } return null ; }
Get the resource at the specified URL as an InputStream