下载URL并返回String
//package com.nowjava; /** n o w j a v a . c o m - 时代Java 提供 **/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String download(URL url) throws IOException { String data = ""; InputStream is = null; HttpURLConnection connection = null; try { connection = (HttpURLConnection) url.openConnection(); /**来自 n o w j a v a . c o m - 时代Java**/ is = connection.getInputStream(); BufferedReader br = new BufferedReader( new InputStreamReader(is)); StringBuffer sb = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); } data = sb.toString(); } catch (IOException e) { e.printStackTr