Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2041518
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类: Java

2009-01-07 09:49:44

import java.io.*;
public class t2 {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  try{
     
      File read = new File("c:\\1.ini");
      File write = new File("c:\\2.ini");
     
      BufferedReader br = new BufferedReader(
            new FileReader(read));
      BufferedWriter bw = new BufferedWriter(
            new FileWriter(write));
      int i=0;
      String temp = null;
      String temp1 ;
      String temp2="";
      i = br.read();
      while(i != -1){
       temp1=(char)i+"";
       if ( i!=10 && i!=13 && !temp1.equals("#")){//"#" 1.ini文件中注释
        temp2="";
        while(!temp1.equals("=")){
         //System.out.println(i);
         //System.out.println((char)i);
        
         temp2=temp2+temp1;
         //temp1 = String.valueOf((char)br.read());
         i=br.read();
         temp1 = (char)i +"";//temp1 = String.valueOf((char)i);
        }
        temp = br.readLine();
        System.out.println(temp2+"="+temp);//可在此处设置INI文件参数,写入2.ini
       }
       else{
        temp = br.readLine();
       }
      i = br.read();
      }
     
      bw.close();
      br.close();
     
     }catch(FileNotFoundException e){ //文件未找到
      System.out.println (e);
     }catch(IOException e){
      System.out.println (e);
     }
 }
}
阅读(1404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~