Here you can find the source of getContentAsString(URL url)
public static String getContentAsString(URL url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.net.URLConnection; public class Main { public static String getContentAsString(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.connect();//from w w w . j ava 2s . c o m InputStream in = conn.getInputStream(); Reader r = new InputStreamReader(in, "UTF-8"); int c; StringBuffer buf = new StringBuffer(); while ((c = r.read()) != -1) { buf.append((char) c); } return buf.toString(); } }