java获取网页内容保存到文件
来源:互联网 发布:template.js 编辑:程序博客网 时间:2024/05/22 01:26
package com.mkyong; import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;import java.net.URLConnection; public class GetURLContent {public static void main(String[] args) { URL url; try {// get URL contenturl = new URL("http://www.mkyong.com");URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReaderBufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream())); String inputLine; //save to this filenameString fileName = "/users/mkyong/test.html";File file = new File(fileName); if (!file.exists()) {file.createNewFile();} //use FileWriter to write fileFileWriter fw = new FileWriter(file.getAbsoluteFile());BufferedWriter bw = new BufferedWriter(fw); while ((inputLine = br.readLine()) != null) {bw.write(inputLine);} bw.close();br.close(); System.out.println("Done"); } catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} }}
0 0
- java获取网页内容保存到文件
- python3 获取网页内容保存到文件
- 获取emoji网页的内容保存到本地
- 获取网页内容,并保存
- 保存网页内容到txt
- java 获取网页内容
- java 获取网页内容
- java获取网页内容
- Java获取网页内容
- C#保存内容到文件
- java用url获取网页内容并输出到控制台
- JAVA HttpURLConnection 获取网页内容
- Java获取网页链接内容
- 利用java获取网页内容
- JAVA HttpURLConnection 获取网页内容
- java socket 获取网页内容
- java获取网页html内容。。。。。。。
- 从URL获取文件保存到本地的JAVA代码
- 四层和七层负载均衡的区别
- 主机电源供电不足导致的系统启动故障
- Spring AOP入门——概念及注意点
- UIScrollView用法
- iOS多线程编程指南(拓展篇)
- java获取网页内容保存到文件
- Spring - the way in the study
- UI中UILable字体表
- 时间复杂度和空间复杂度详解
- Android SDK 坏境配置 转载于百度经验
- 专业设计师有哪些必知的设计流程
- 微软讲座视频: 下一代vNext平台:ASP.NET vNext与MVC6,WebAPI 3.0 新特性 下载
- ZOJ 1394 Polar Expoler
- 在linux下如何编译C++程序