Here you can find the source of readData(String url)
public static String readData(String url)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String readData(String url) { StringBuilder data = new StringBuilder(); try {//from w ww . j a v a 2 s . c o m BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream())); String line; while ((line = in.readLine()) != null) { data.append(line); } in.close(); } catch (MalformedURLException e) { System.out.println("Malformed URL: " + e.getMessage()); } catch (IOException e) { System.out.println("I/O Error: " + e.getMessage()); } return data.toString(); } }