Here you can find the source of downloadTextFromUrl(String url)
public static String downloadTextFromUrl(String url)
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.Scanner; public class Main { /**/* w w w . jav a 2 s.c o m*/ * Downloads text from a given URL and returns it as a String * * @return the text (or null if download failed) */ public static String downloadTextFromUrl(String url) { InputStream in; try { in = new URL(url).openStream(); Scanner scan = new Scanner(in); return scan.hasNext() ? scan.next() : null; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } } }