论坛首页 Java企业应用论坛

替换properties文件里的字符串

浏览 2111 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-05-09  
         public static void main(String[] args) throws IOException
{
File f = new File(System.getProperty("user.dir")+"\\b.properties");
FileReader fr = new FileReader(f);

BufferedReader br = new BufferedReader(fr);

String line = null;
StringBuffer sb = new StringBuffer();
while((line = br.readLine()) != null)
{
System.out.println(line);
line = line.replaceAll("\\\\:", ":");
System.out.println(line.replaceAll("\\:", ":") + "......");
System.out.println(line);
sb.append(line);
}
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
bw.write(sb.toString());

br.close();
bw.close();
}
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics