Here you can find the source of downloadAsString(String url)
public static String downloadAsString(String url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; public class Main { public static String downloadAsString(String url) throws IOException { try (InputStream is = new URL(url).openStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr)) { StringBuilder sb = new StringBuilder(); String line;/*w w w .j a va2 s. c o m*/ while ((line = br.readLine()) != null) { sb.append(line).append('\n'); } return sb.toString(); } } }