Here you can find the source of getStringFromURL(String URLString)
public static String getStringFromURL(String URLString)
//package com.java2s; //License from project: Creative Commons License import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String getStringFromURL(String URLString) { try {// w ww .jav a2 s.c om URL URL = new URL(URLString); HttpURLConnection connection = (HttpURLConnection) URL .openConnection(); connection .setRequestProperty( "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); connection.setDoInput(true); BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream())); return reader.readLine(); } catch (Exception e) { return ""; } } }