回覆列表
  • 1 # 吖被你發現了

    java實現:用URLConnection開啟指定的url,然後用InputStream讀入網頁內容,將讀入的內容存入String中,這個程式網上有很多。import java.io.*;import java.net.*;public class VisitWeb {public String getWeb(String url) {try {StringBuffer txt = new StringBuffer();URL url = new URL(url);URLConnection conn = url.openConnection();conn.setDoOutput(true);InputStream in = conn.getInputStream();InputStreamReader inReader = new InputStreamReader(in);BufferedReader reader = new BufferedReader(inReader);String rdline = "";while((rdline=reader.readLine())!=null) {txt.append(rdline+"\n");}} catch(Exception e) {e.printStackTrace();}return txt.toString();}}

  • 中秋節和大豐收的關聯?
  • 如何減排溫室氣體?