在 Windows 中使用 Eclipse。
此代码适用于 JRE 1.8(Comp 级别 1.7)桌面,(字符串不为空)。
但它在 Droid 中不起作用(Comp level 1.7 - 4.4W.2 API-20)(字符串为空):
代码:
RuleBasedCollator collTemp = (RuleBasedCollator) Collator.getInstance(Locale.US);
String usRules = collTemp.getRules(); //==String is Empty - why?
usRules = usRules.replace(",'-'", "");
最佳答案
Android 文档对 getRules() 方法有这样的说明
The returned string will be empty unless you constructed the instance yourself. The string forms of the collation rules are omitted to save space on the device.
您可以使用整理器,但它不会返回字符串表示形式。
http://developer.android.com/reference/java/text/RuleBasedCollator.html#getRules()
关于java - RuleBasedCollator getInstance Locale.US getRules 在 Droid 中返回空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31416957/