guyongpeng 发表于 2013-1-14 23:08:19

对unicode资源文件进行反native2ascii化

在使用derby时,出现了

[*]Caused by: org.apache.derby.client.am.SqlException: 请求的时间内无法获取锁异常
google了一下没有结果,改为google

[*]Caused by: org.apache.derby.client.am.SqlException: lock

出来了一大堆信息,其中有很多是


[*]Caused by: org.apache.derby.client.am.SqlException: A lock could not be obtained within the time requested

为了确认“请求的时间内无法获取锁”即对应于“A lock could not be obtained within the time requested”,需要把locale为zh_CN的一大堆properties文件里的中文字符的unicode信息反native2ascii出来,进行查找,将查找到的key到locale为en_US中进行比对。写了个小程序如下:

public static void native2asciiReverse() {File srcFolder = new File("d:/loc");File[] srcFiles = srcFolder.listFiles();for (File file : srcFiles) {if (file.isFile()) {try {String command = "C:/Program Files/Java/jdk1.5.0_06/bin/native2ascii.exe -reverse "+ file.getAbsolutePath()+ " d:/loc_new/"+ file.getName().replaceAll(".properties", ".txt");Runtime.getRuntime().exec(command);} catch (IOException e) {e.printStackTrace();}}}}
这样就能在文件系统中查找“请求的时间内无法获取锁”了。
PS:目标文件后缀改为txt是因为windows文件系统查找不到properties里的字符串。
页: [1]
查看完整版本: 对unicode资源文件进行反native2ascii化