Here you can find the source of readURLText(String urlPath, String encoding)
public static String readURLText(String urlPath, String encoding)
//package com.java2s; //License from project: Apache License import java.io.*; import java.net.URL; public class Main { public static String readURLText(String urlPath, String encoding) { BufferedReader br = null; try {/*from w ww . j a v a 2s .c om*/ URL url = new URL(urlPath); br = new BufferedReader(new InputStreamReader(url.openStream(), encoding)); StringBuffer sb = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } return sb.toString(); } catch (Exception e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; } }