zoukankan      html  css  js  c++  java
  • java 实验五保存网页到本地

    实验要求:

     编写一个程序,实现访问一个网址吧并将指定的一个页面保存到本地。、

    package 实验五保存网站;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    
    public class testMain {
        public static void main(String argv[]) 
        {
            try
            {
                URL url=null;
                url=new URL("https://www.baidu.com/");
                BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream()));
                File infile =new File("file.html");
                FileWriter fin=new FileWriter(infile);
                String line;
                while((line=in.readLine())!=null)
                {
                    fin.write(line);
                }
                fin.close();
                in.close();
            }catch (MalformedURLException e) {
                // TODO 自动生成的 catch 块
                e.printStackTrace();
            }catch (IOException e) {
                // TODO 自动生成的 catch 块
                e.printStackTrace();
            }
        }
    }
  • 相关阅读:
    k8s nod rc service 使用
    Linux $() 与 ${}
    Linux set
    Linux 上传下载 rz 与sz
    Linux !的使用
    K8s创建pod yaml文件详解
    Kubernetes 安装
    Python 生成器
    k8s 使用详解
    微信 网页授权
  • 原文地址:https://www.cnblogs.com/lhclqslove/p/9175037.html
Copyright © 2011-2022 走看看