判断 java 源文件是否有中文
此代码主要用于扫描 java 源文件是否包含有中文,为了方便对于国际化时修改
java 文件时遗忘掉对应的代码。所用类都为 java 基础类 ,可以直接执行。
lass FileSystem {
publicstaticint count = 0; // 用于计数, java 文件中存在中文
publicstaticvoid main(String[] args ) {
long a = System. currentTimeMillis ();
System. out
.println( refreshFileList ( "" )); // 某一个文件夹
System. out .print( " 所用时间: " );
System. out .println(System. currentTimeMillis () - a);
}
// 用递归获取某个文件夹下的所有 java 文件
publicstaticint refreshFileList(String strPath ){
File dir = new File( strPath );
File[] files = dir .listFiles();
if ( files == null ) {
return 0;
}
for ( int i = 0; i <files . length ; i ++) {
if ( files [ i ].isDirectory()) {
refreshFileList ( files [ i ].getAbsolutePath());
} else {
if ( files [ i ].getAbsolutePath().indexOf( ".java" ) >= 0) {
String strFileName = files [ i ].getAbsolutePath();
if ( CheckIsChinese ( strFileName )) {
count ++;
System. out .println( count +": " + strFileName + " 存
在中文! " );
} /*
* else { ("##" + strFileName +
"
* 没有存在中文! "); }
*/
}
}
}
return count ;
}
privatestaticfinalboolean isChinese( char c ) {
ub = . of ( c);
if ( ub == . CJK_UNIFIED_IDEOGRAPHS
|| ub ==
. PATIBILITY_IDEOGRAPHS
|| ub ==
. CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == . G
判断java源文件是否包含中文 来自淘豆网m.daumloan.com转载请标明出处.