下载网页代码
public static String readUrl(String urlName, String encoding) {try {StringBuffer sb = new StringBuffer();URL url = new URL(urlName);URLConnection conn = url.openConnection();conn.setConnectTimeout(30 * 1000);conn.setReadTimeout(30 * 1000);BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), encoding));String line;while ((line = br.readLine()) != null) {sb.append(line);}return sb.toString();} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return null;}?
BufferedReader的方法readLine()适用于读取文本,对于二进制文件不适合
?
?