Here you can find the source of readTextURL(URL url)
public static String readTextURL(URL url)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.net.URL; import java.util.Scanner; public class Main { public static String readTextURL(URL url) { try {/*from w ww . ja va 2s. c o m*/ return readText(url.openStream()); } catch (Exception e) { throw new RuntimeException("Reading from URL \"" + url + "\" failed", e); } } public static String readText(InputStream in) { StringBuilder text = new StringBuilder(); Scanner scanner = new Scanner(in); while (scanner.hasNextLine()) { text.append(scanner.nextLine() + "\n"); } return text.toString(); } }