标签:pen cep amr str except java读取 raw try system
package com.linxinxin.tools;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class CrawlerUtil {
public static void main(String[] a){
try {
URL url=new URL("http://www.baidu.com");
BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter writer=new BufferedWriter(new FileWriter("index.html"));
String line;
while((line=reader.readLine())!=null){
System.out.println(line);
writer.write(line);
writer.newLine();
}
reader.close();
writer.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
标签:pen cep amr str except java读取 raw try system
原文地址:https://www.cnblogs.com/itzyz/p/12241999.html