多语言的资源包文件比较检查,自动核对。package com.smeishop.util; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; /* * 比较资源包是否相同 * 修改file1和file2的路径,运行来比较 */ public class ComparatorProperties { public static void main(String[] args) { String file1 = "E://globalMessages_en.properties"; String file2 = "E://globalMessages_zh.properties"; ComparatorProperties cp = new ComparatorProperties(); cp.ComparatorStart(new File(file1),new File(file2)); } public void ComparatorStart(File file1, File file2) { try { FileReader fr1 = new FileReader(file1); BufferedReader br1 = new BufferedReader(fr1); FileReader fr2 = new FileReader(file2); BufferedReader br2 = new BufferedReader(fr2); String readoneline1, readoneline2, prop1, prop2; int k; k = 0; while ((readoneline1 = br1.readLine()) != null) { k++; readoneline2 = br2.readLine(); if (readoneline1 != null && readoneline2 != null) { if (!readoneline1.equals(readoneline2)) { if (!readoneline1.equals("") && !readoneline1.equals("")) { if (readoneline1.charAt(0) == readoneline2.charAt(0)) { if (readoneline1.charAt(0) == "#".charAt(0) || readoneline1.charAt(0) == "#".charAt(0)) { continue; } else { prop1 = readoneline1.split("=")[0]; prop2 = readoneline2.split("=")[0]; if (!prop1.equals(prop2)) { System.out.println("error on line " + k); System.out.println("File /"" + file1.getName() + "/" line " + k + " : " + prop1); System.out.println("File /"" + file2.getName() + "/" line " + k + " : " + prop2); break; } } } else { System.out.println("error on line " + k); System.out.println("first char different " + readoneline1); System.out.println("first char different " + readoneline2); System.out.println("File /"" + file1.getName() + "/" line " + k + " first char : " + readoneline1.charAt(0)); System.out.println("File /"" + file2.getName() + "/" line " + k + " first char : " + readoneline2.charAt(0)); break; } } else { System.out.println("2error on line " + k); break; } } } else { System.out.println("error on line " + k); break; } } } catch (IOException e) { } } } 代码很简单,用的着的拿去用吧。