源码如下:publicclassnetbug{publicstaticvoidmain(String[]args){newnetbug().methodPa("http://gzcx.hbjt.gov.cn:808/AjaxPages/WayEvent/wayevent_he.aspx?id=262612");}publicst...
源码如下:
public class netbug{
public static void main(String[] args){
new netbug().methodPa("http://gzcx.hbjt.gov.cn:808/AjaxPages/WayEvent/wayevent_he.aspx?id=262612");
}
public static void methodPa(String strURL){
String tem,string = null;
try{
URL url = new URL(strURL);
HttpURLConnection conn =(HttpURLConnection)url.openConnection();
InputStreamReader isr = new InputStreamReader(conn.getInputStream(),"UTF-8");
BufferedReader br = new BufferedReader(isr);
while((tem = br.readLine()) != null){
string=Html2Text(tem);//过滤html标签
System.out.println(string);
}
try {
BufferedWriter rw = new BufferedWriter(new FileWriter("c://xxy.txt"));
rw.write(string);
rw.close();
} catch (Exception e) {
e.printStackTrace();
}
br.close();
isr.close();
}catch(Exception e){ e.printStackTrace(); }
}
展开