Here you can find the source of getContentFromURL(String sURL)
public static String getContentFromURL(String sURL)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.net.URL; import java.util.Scanner; public class Main { public static String getContentFromURL(String sURL) { String content = "ERROR"; URL url = null;/*from ww w . j a v a 2 s. c o m*/ try { url = new URL(sURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); Scanner s; if (connection.getResponseCode() != 200) { s = new Scanner(connection.getErrorStream()); } else { s = new Scanner(connection.getInputStream()); } s.useDelimiter("\\Z"); content = s.next(); } catch (Exception e) { e.printStackTrace(); } return content; } }