李敏  
日历
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
统计
  • 随笔 - 1
  • 文章 - 40
  • 评论 - 4
  • 引用 - 0

导航

常用链接

留言簿(1)

文章分类

文章档案

相册

收藏夹

它山之石

聚贤庄

搜索

  •  

最新评论

 

import java.io.*;

public class CancelNumber{
  private String inFile;
  private String outFile;
 
  public CancelNumber(){
  }
 
  public CancelNumber(String inFile,String outFile){
    this.inFile=inFile;
   
    this.outFile=outFile;
  }
 
  public void test(){
     BufferedReader in;
    
     BufferedWriter out;
    
     try{
        in=new BufferedReader(new FileReader(inFile));
       
        out=new BufferedWriter(new FileWriter(outFile));
       
        StringBuffer sb=new StringBuffer();
       
        String context;
       
        int i=1;
    
        while((context=in.readLine())!=null&&context.length()!=0){
           String temp=getCode(context);
          
           sb.append(temp);
        }
       
        out.write(sb.toString().trim());

        in.close();
       
        out.close();
       
     }catch(FileNotFoundException e){
        e.printStackTrace();
     }catch(IOException e){
        e.printStackTrace();
     }
  }
 
  public String getCode(String context){
     context=context.trim();
    
     int index=0;

     int asc=0;
    
     for(int i=0;i<context.length();i++){
        asc=(int)context.charAt(i);
       
        if(!(asc>=48&&asc<=57)){
           index=i;
           break;
        }
     }
    
    if(index==0&&asc<65)
     context="";                              //去掉只有数字的行,字母最小的ASCII值为65(a)
    else
    context=context.substring(index)+"\n";   //去掉开头的数字(正常流程)
 
     return context;
  }
 
  public static void main(String[]args){
 
      String inFile=args[0];
     
      String outFile=args[1];
 
      new CancelNumber(inFile,outFile).test();
  }
}

posted on 2009-02-16 15:49 李敏 阅读(380) 评论(0)  编辑  收藏 所属分类: 算法

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © 李敏 Powered by: 博客园 模板提供:沪江博客