URL保存本地

try {
            URL url = new URL("https://www.baidu.com");   //想要读取的url地址
            File fp = new File("D:/test.html");
            OutputStream os = new FileOutputStream(fp);          //建立文件输出流
            URLConnection conn = url.openConnection();          //打开url连接
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String urlString = "";
            String current;
            while ((current = in.readLine()) != null) {
                urlString += current;
            }
            os.write(urlString.getBytes());
            os.close();

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

 

URL保存本地

上一篇:rgb转16进制js方法,npm插件


下一篇:thinkphp-2x-rce 代码执行