Here you can find the source of readContentsToString(URL url)
public static String readContentsToString(URL url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.net.URL; public class Main { public static String readContentsToString(URL url) throws IOException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(url.openStream())); StringBuilder content = new StringBuilder(); String line;/*from www . java2 s. c om*/ while ((line = reader.readLine()) != null) content.append(line); return content.toString(); } }