李敏  
          日歷
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789
          統(tǒng)計
          • 隨筆 - 1
          • 文章 - 40
          • 評論 - 4
          • 引用 - 0

          導(dǎo)航

          常用鏈接

          留言簿(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="";                              //去掉只有數(shù)字的行,字母最小的ASCII值為65(a)
              else
              context=context.substring(index)+"\n";   //去掉開頭的數(shù)字(正常流程)
           
               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 李敏 閱讀(406) 評論(0)  編輯  收藏 所屬分類: 算法
           
          Copyright © 李敏 Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 延川县| 陇川县| 宁夏| 斗六市| 鄂托克前旗| 长宁区| 镇赉县| 阜康市| 芜湖市| 尼勒克县| 石楼县| 电白县| 雅江县| 洛南县| 旬邑县| 清原| 屯门区| 巧家县| 雅江县| 南充市| 商丘市| 渑池县| 河池市| 漳州市| 南平市| 承德县| 瑞丽市| 庐江县| 铜山县| 保亭| 周宁县| 梁河县| 龙江县| 华亭县| 东至县| 冷水江市| 临潭县| 天镇县| 岱山县| 宜阳县| 双峰县|