集册 Java实例教程 从web读取html文件

从web读取html文件

欢马劈雪     最近更新时间:2020-01-02 10:19:05

515
从web读取html文件

import java.io.BufferedReader;

import java.io.BufferedWriter;
/**
nowjava - 时  代  Java 提供 
**/

import java.io.FileWriter;

import java.io.InputStreamReader;

import java.net.URL;


public class Main {

   public static void main(String[] args) 

   throws Exception {

      URL url = new URL("http://your server.com/index-4.html");

      BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));

      BufferedWriter writer = new BufferedWriter(new FileWriter("data.html"));

      String line;

      while ((line = reader.readLine()) != null)
展开阅读全文