Here you can find the source of loadFromUrl(String url)
public static String loadFromUrl(String url) throws MalformedURLException, IOException
//package com.java2s; /**/*from w w w. j a v a 2 s . co m*/ * Copyright 2010 ZTEsoft Inc. All Rights Reserved. * * This software is the proprietary information of ZTEsoft Inc. * Use is subject to license terms. * * $Tracker List * * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 * * */ import java.io.*; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String loadFromUrl(String url) throws MalformedURLException, IOException { StringBuffer sb = new StringBuffer(); URL u = new URL(url); InputStream in = u.openStream(); byte[] buf = new byte[1024]; try { while (true) { int n = in.read(buf); sb.append(new String(buf, 0, n)); if (n < 1024) { break; } } } catch (IOException ex) { in.close(); throw ex; } finally { in.close(); } return sb.toString(); } public static String toString(Object val) { if (val == null) { return ""; } return val.toString(); } public static String toString(Object[] objs) { if (objs != null && objs.length > 0) { StringBuffer buff = new StringBuffer(); for (int i = 0; i < objs.length; i++) { buff.append("\nItem[").append(i).append("]\n").append(objs[i]); } return buff.toString(); } else { return ""; } } public static String toString(int val) { return Integer.toString(val); } public static String toString(float val) { return Float.toString(val); } public static String toString(double val) { return Double.toString(val); } public static String toString(long val) { return Long.toString(val); } public static String toString(short val) { return Short.toString(val); } public static String toString(boolean val) { return Boolean.toString(val); } }