java实现复制网站内容

时间:2024-04-16 13:54:53

复制网站内容
复制代码
本程序将网站“www.baidu.com”首页的内容复制保存在文件test.html中。写了如下代码,请完善之:

import java.net.*;
import java.io.*;
class DaSai{
    public static void main(String[] args) throws Exception {
        URL url=__________________________________;
        BufferedReader in =_________________________________;
        String inString;     
        File outfile=new File("test.html");      
        PrintWriter out=new PrintWriter(new FileWriter(outfile));
        while ((inString=in.readLine())!=null){ 
               out.println(inString);
        }
        in.close(); 
        out.close();
     }
 }


new URL("http://www.baidu.com")

new BufferedReader(new InputStreamReader(url.openStream()))