用JSP抓取网址 - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 用JSP抓取网址 (http://www.webasp.net/article/26/25573.htm) |
| -- 作者:未知 -- 发布日期: 2005-07-08 |
import java.io.*; class url2htm{ static private url2htm instance; // Create the only instance of the class public static String strURL=""; // Announce the universial variable to mark the destination URL public static String strFile=""; // Announce the universial variable to mark the local file path /** init(); } url2htm instUrl2htm = new url2htm(); // Create the instance of the default class instUrl2htm.write(); // Invoke the chief function /** Enumeration propNames = props.propertyNames(); while(propNames.hasMoreElements()){ String name = (String) propNames.nextElement(); if(name.endsWith(".url")){ String webName = name.substring(0,name.lastIndexOf(".")); strURL = props.getProperty(webName + ".url"); strFile = props.getProperty(webName + ".file"); } /** System.out.println(strURL); } /** System.out.println(strFile); } /** String fileline; String url = strURL; try { URL destURL = new URL(url); InputStream in = destURL.openStream(); BufferedReader filedata = new BufferedReader(new InputStreamReader(in)); FileOutputStream out = new FileOutputStream(strFile); PrintStream prtStream = new PrintStream(out); while ((fileline = filedata.readLine()) != null) { prtStream.println(fileline + "\n"); } } catch (IOException e) { System.out.println("Error in I/O:" + e.getMessage()); } } /** InputStream is = getClass().getResourceAsStream("web.properties"); // Data input stream Properties webProps = new Properties(); try catch (Exception e) |
| webasp.net |