Multi-language resource package file comparison check, automatic check.
Package COM. smeishop. util; </P> <p> Import Java. io. bufferedreader; <br/> Import Java. io. file; <br/> Import Java. io. filereader; <br/> Import Java. io. ioexception; </P> <p>/* <br/> * compare whether the resource package is the same <br/> * modify the path of file1 and file2, run to compare <br/> */<br/> public class comparatorproperties {<br/> Public static void main (string [] ARGs) {<br/> string file1 = "E: // globalmessages_en.properties"; <br/> string file2 = "E: // globalmessa Ges_zh.properties "; <br/> comparatorproperties CP = new comparatorproperties (); <br/> CP. comparatorstart (new file (file1), new file (file2); <br/>}</P> <p> Public void comparatorstart (File file1, file file2) {<br/> try {<br/> filereader fr1 = new filereader (file1); <br/> bufferedreader br1 = new bufferedreader (fr1 ); </P> <p> filereader FR2 = new filereader (file2); <br/> bufferedreader Br2 = new bufferedreade R (FR2); <br/> string readoneline1, readoneline2, prop1, prop2; <br/> int K; <br/> K = 0; </P> <p> while (readoneline1 = br1.readline ())! = NULL) {<br/> K ++; <br/> readoneline2 = br2.readline (); <br/> If (readoneline1! = NULL & readoneline2! = NULL) {<br/> If (! Readoneline1.equals (readoneline2) {<br/> If (! Readoneline1.equals ("")&&! Readoneline1.equals ("") {<br/> If (readoneline1.charat (0) = readoneline2.charat (0) {<br/> If (readoneline1.charat (0) = "#". charat (0) <br/> | readoneline1.charat (0) = "#". charat (0) {<br/> continue; <br/>}else {<br/> prop1 = readoneline1.split ("=") [0]; <br/> prop2 = readoneline2.split ("=") [0]; <br/> If (! Prop1.equals (prop2) {<br/> system. out. println ("error on line" + k); <br/> system. out. println ("file/" "+ file1.getname () +"/"line" <br/> + K + ":" + prop1); <br/> system. out. println ("file/" "+ file2.getname () +"/"line" <br/> + K + ":" + prop2); <br/> break; <br/>}< br/>} else {<br/> system. out. println ("error on line" + k); <br/> system. out. println ("first char different" + readoneline1); <br/> system. out. println ("first char different" + readoneline2); <br/> system. out. println ("file/" "+ file1.getname () +"/"line" + k <br/> + "first CHAR:" + readoneline1.charat (0 )); <br/> system. out. println ("file/" "+ file2.getname () +"/"line" + k <br/> + "first CHAR:" + readoneline2.charat (0 )); <br/> break; <br/>}< br/>} else {<br/> system. out. println ("2 error on line" + k); <br/> break; <br/>}< br/>} else {<br/> system. out. println ("error on line" + k); <br/> break; <br/>}< br/>} catch (ioexception E) {<br/>}< br/>
the Code is simple. Use it.