本帖最后由 flymaxdragon 于 2010-08-08 12:52:25 编辑

解决方案 »

  1.   


    import java.io.*;
    public class Read
    {
      public static void main(String[] args) {
               try{
               readText();
               }catch(Exception e){}
           }
      public static void readText() throws Exception {
     
    //读取源文本文件
            String read="";
            BufferedReader sb=null;
            try{
            sb=new BufferedReader(new FileReader("source.txt"));
    boolean start=false;
    while(true){
      String temp=sb.readLine();
      if(temp.indexOf("class_5")!=-1){
          start=true;
     }else if(temp.startsWith(")")){
     start=false;
     }  if(start){
     read+=temp+"\r\n";
     }
    }
          }catch(Exception e){}  
        
    //将读取的字符串写进dest.txt文本文件中
    BufferedWriter bw=new BufferedWriter(new FileWriter("dest.txt"));
    bw.write(read);
            bw.write(")");
           sb.close();
    bw.close();
          
      }
    }