本文整理汇总了Java中java.util.Properties.elements方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.elements方法的具体用法?Java Properties.elements怎么用?Java Properties.elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixMessages
import java.util.Properties; //导入方法依赖的package包/类
/**
* This method was introduced to fix defect #26964. For Java 1.0.2
* on Win NT, the escape sequence \u0020 was not being handled
* correctly by the Java Properties class when it was the final
* character of a line. Instead the trailing blank was dropped
* and the next line was swallowed as a continuation. To work
* around the problem, we introduced our own metasymbol to represent
* a trailing blank. Hence:
*
* Performs substitution for any metasymbols in the message
* templates. So far only %B is needed. This was introduced
* to make it more convenient for .properties files to
* contain message templates with leading or trailing blanks
* (although %B may actually occur anywhere in a template).
* Subsequently, checking for '\n' has also been added. Now,
* wherever '\n' occurs in a message template, it is replaced
* with the value of System.getProperty ("line.separator").
*/
private static final void fixMessages (Properties p) {
Enumeration keys = p.keys ();
Enumeration elems = p.elements ();
while (keys.hasMoreElements ()) {
String key = (String) keys.nextElement ();
String elem = (String) elems.nextElement ();
int i = elem.indexOf (LTB);
boolean changed = false;
while (i != -1) {
if (i == 0)
elem = " " + elem.substring (2);
else
elem = elem.substring (0, i) + " " + elem.substring (i+2);
changed = true;
i = elem.indexOf (LTB);
}
int lsIncr = lineSeparator.length () - 1;
for (i=0; i<elem.length (); i++) {
if (elem.charAt (i) == NL) {
elem = elem.substring (0, i) +
lineSeparator + elem.substring (i+1);
i += lsIncr;
changed = true;
}
}
if (changed)
p.put (key, elem);
}
}