把jsptohtml的格式

package com.erry.util;

   
  import   javax.servlet.http.HttpServletRequest;  
  import   java.util.List;  
  import   java.util.ArrayList;  
  import   java.net.URL;  
  import   java.net.URLConnection;  
  import   java.io.*;  
   
  /**  
    *   Filename:   JspToHtml.java  
    *   Ttitle:  
    *   Description:  
    *   Copyright:         Copyright   (c)   2001-2004   BlueStar,Inc.All   Rights   Reserved.  
    *   Company:           bluestar  
    *   Author:             <a   href="mailto:lanxingsc@163.com">wuyang</a>  
    *   Telephone:       86-28-85239210  
    *   Date:   2004-6-19  
    *   Time:   16:41:09  
    *   Version:   1.0.1.0000  
    */  
  public   class   JspToHtml   {  
   
          /**  
            *   根据url另外为html页面  
            *   从属性文件bluestr中读取属怄1�7     TO_HTML_FILE  
            *   如:TO_HTML_FILE   =   index.do,aaa.html||error.jsp,errot.html  
            *  
            *   @param   request  
            */  
          public   static   void   JspToHtmlByProp(HttpServletRequest   request)   {  
//                  String   path   =   WebSite.getHostPath(request);  
           String path  = request.getRealPath("");
//                  String   realPath   =   request.getRealPath("/");  
//                  String   JspFile   =   "",   HtmlFile   =   "";  
                  String   htmlFileString   =   ConfigUtil.getProp("TO_HTML_FILE"); 
                String   htmlFileString   =   ConfigUtil.getProp("TO_HTML_FILE"); 
//                  List   l   =   StringUtil.splitList(htmlFileString,   "||");  
//                  if   (l   ==   null)   l   =   new   ArrayList();  
//                  for   (int   k   =   0;   k   <   l.size();   k++)   {  
//                          String   temp   =   (String)   l.get(k);  
//                          String   str   =   "";  
//                          JspFile   =   temp.substring(0,   temp.indexOf(","));  
//                          HtmlFile   =   temp.substring(temp.indexOf(",")   +   1,   temp.length());  
//                          //从utl中读取html存为str  
//                          try   {  
//                                  URL   url   =   new   URL(path   +   JspFile);  
//                                  URLConnection   uc   =   url.openConnection();  
//                                  InputStream   is   =   uc.getInputStream();  
//                                  BufferedReader   br   =   new   BufferedReader(new   InputStreamReader(is));  
//                                  while   (br.ready())   {  
//                                          str   +=   br.readLine()   +   "\n";  
//                                  }  
//                                  is.close();  
//                          }   catch   (IOException   e)   {  
//                                  e.printStackTrace();  
//                          }  
//                          //写入文件  
//                          try   {  
//                                  File   f   =   new   File(realPath   +   HtmlFile);  
//                                  BufferedWriter   o   =   new   BufferedWriter(new   FileWriter(f));  
//                                  o.write(str);  
//                                  o.close();  
//                          }   catch   (IOException   e)   {  
//                          }  
//                  }  
          }  
   
          /**  
            *   根据url生成静�1�7�页靄1�7  
            *  
            *   @param   u         动�1�7�文件路组1�7   如:http://www.sina.com/kkk.jsp  
            *   @param   path   文件存放路经如:d:\\aaa\bbb.html  
            *   @return  
            */  
          public   static   boolean   JspToHtmlByURL(String   u,   String   path)   {  
                  //从utl中读取html存为str  
                  String   str   =   "";  
                  try   {  
                          URL   url   =   new   URL(u);  
                          URLConnection   uc   =   url.openConnection();  
                          InputStream   is   =   uc.getInputStream();  
                          BufferedReader   br   =   new   BufferedReader(new   InputStreamReader(is));
                         
                          while   (br.ready())   {  
                                  str   +=   br.readLine()   +   "\n";  
                          }  
                          is.close();  
                          //写入文件  
                          File   f   =   new   File(path);  
                          BufferedWriter   o   =   new   BufferedWriter(new   FileWriter(f));  
                          o.write(str);  
                          o.close();  
                          return   true;  
                  }   catch   (IOException   e)   {  
                          e.printStackTrace();  
                          return   false;  
                  }  
          }  
   
          /**  
            *   测试  
            *    
            *   @param   arg  
            */  
          public   static   void   main(String[]   arg)   {  
                  String   url   =   "http://localhost/site/index.do";  
//                  String   savepath   =   "d:\\bb\\aaa.html";  
                  String   savepath=  "C:\\jboss-4.0.4.GA\\server\\default\\deploy\\mag-gatewayApp.war\\site\\aa.html";
                  JspToHtmlByURL(url,   savepath);  
                  System.out.println("end");
          }  
  }  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值