程序打包时发现存在中文时不能正常打包。文件目录又太多,就写了下面的一段搜索中文名文件。试了下局域网路径也可以。
/**
* @author Wesley
*/
public class SearchChineseFile {
private static ArrayList filelist = new ArrayList();
private static final String regex_CHN = ".*[\\u4e00-\\u9fa5]+.*";
private static Pattern pattern_CHN = Pattern.compile(regex_CHN);
public static void main(String[] args) throws IOException {
long a = System.currentTimeMillis();
BufferedReader stdin = new BufferedReader(new InputStreamReader(
System.in));
String fDir = stdin.readLine();
refreshFileList(fDir);
System.out.println(System.currentTimeMillis() - a);
System.out
.println("-------------------------中文名文件----------------------------");
for (Iterator it = filelist.iterator(); it.hasNext();) {
System.out.println(it.next().toString());
}
}
public static void refreshFileList(String strPath) {
File dir = new File(strPath);
File[] files = dir.listFiles();
if (files == null)
return;
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
refreshFileList(files[i].getAbsolutePath());
} else {
String strFileName = files[i].getAbsolutePath().toLowerCase();
if (isCHN(files[i].getAbsoluteFile().toString())) {
System.out.println("----------" + strFileName
+ "--------------");
filelist.add(files[i].getAbsolutePath());
}
}
}
}
public static boolean isCHN(String str) {
Matcher m = pattern_CHN.matcher(str);
if (m.matches())
return true;
else
return false;
}
}