Java Code Examples for java.util.Properties#elements()
The following examples show how to use
java.util.Properties#elements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenPropertiesSize_whenPropertyFileLoaded_thenCorrect() throws IOException { String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath(); String appPropsPath = rootPath + "app.properties"; Properties appProps = new Properties(); appProps.load(new FileInputStream(appPropsPath)); appProps.list(System.out); // list all key-value pairs Enumeration<Object> valueEnumeration = appProps.elements(); while (valueEnumeration.hasMoreElements()) { System.out.println(valueEnumeration.nextElement()); } Enumeration<Object> keyEnumeration = appProps.keys(); while (keyEnumeration.hasMoreElements()) { System.out.println(keyEnumeration.nextElement()); } int size = appProps.size(); assertEquals(3, size); }
Example 2
Source File: Messages.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 3
Source File: Messages.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 4
Source File: Messages.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 5
Source File: Messages.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 6
Source File: Messages.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 7
Source File: Messages.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 8
Source File: Messages.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 9
Source File: Messages.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }