Multi-language resource package file comparison check, automatic check.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.