读一个文本Html网页

package test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            FileReader fr=new FileReader("index.html");
            BufferedReader br=new BufferedReader(fr);
            
            String line=null;
            
            while((line=br.readLine())!=null){
                String t=line.replace("\"","'");
                
                System.out.println("out.println(\""+t+"\");");                
            }
            
            
            br.close();
            fr.close();
            
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        

    }

}

 

package test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        try {
            FileReader fr=new FileReader("index_gbk.html");
            BufferedReader br=new BufferedReader(fr);
            
            String line=br.readLine();
            while(line!=null){
                String ok=line.replace('\"', '\'');  //ȥ��˫���  �䵥��
                ok="out.println(\""+ok+"\");";   //   out.println("info");
                System.out.println(ok);
                line=br.readLine();
            }
            
            br.close();
            fr.close();
            
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        

    }

}

 

posted @ 2012-10-20 18:57  邹晟  阅读(202)  评论(0编辑  收藏  举报