李敏  
          日歷
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789
          統計
          • 隨筆 - 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 李敏 閱讀(406) 評論(0)  編輯  收藏 所屬分類: 算法
           
          Copyright © 李敏 Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 都兰县| 右玉县| 广水市| 板桥市| 瑞丽市| 虹口区| 清水县| 夏邑县| 三亚市| 东乡| 灵石县| 巫山县| 金阳县| 台东市| 和田市| 噶尔县| 大足县| 始兴县| 大悟县| 汉寿县| 砀山县| 康平县| 偏关县| 尼勒克县| 香格里拉县| 宁河县| 宝坻区| 罗田县| 沙雅县| 临沂市| 绵竹市| 积石山| 贺州市| 太谷县| 遵义市| 夏河县| 阿巴嘎旗| 桃园县| 保亭| 陕西省| 波密县|