public static String getUrlContents ( String urlString ) { HttpURLConnection con = null ; try { URL url = new URL ( urlString ) ; con = ( HttpURLConnection ) url . openConnection ( ) ; con . connect ( ) ; InputStream inputStream = con . getInputStream ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; StringBuffer contents = new StringBuffer ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { contents . append ( line ) ; contents . append ( JK . NEW_LINE ) ; } inputStream . close ( ) ; return contents . toString ( ) ; } catch ( Exception e ) { JKExceptionUtil . handle ( e ) ; return null ; // unreachable } finally { if ( con != null ) { con . disconnect ( ) ; } } }
Gets the url contents .