Iterate Map
From Java Example Source Code
Contents |
[edit] Overview - Iterate Map
This Java example program introduce Iterate Map.
[edit] Java Source Code
- Package: example.systemproperties
- File: DumpProps.java
package example.systemproperties; import java.util.Enumeration; import java.util.Iterator; import java.util.Map; import java.util.Properties; public class DumpProps { public static void main(String args[]) { Properties props = System.getProperties(); Iterator iter = props.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " --- " + entry.getValue()); } System.out.println("-------"); Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " --- " + props.getProperty(key)); } } }
[edit] What Result You Can Get
Run the program, you will get:
java.runtime.name --- Java(TM) SE Runtime Environment sun.boot.library.path --- D:\jdk\j2se\jre\bin java.vm.version --- 1.6.0-b105 java.vm.vendor --- Sun Microsystems Inc. java.vendor.url --- http://java.sun.com/ path.separator --- ; java.vm.name --- Java HotSpot(TM) Client VM file.encoding.pkg --- sun.io sun.java.launcher --- SUN_STANDARD user.country --- US ...
[edit] Required External Libraries and/or Files for this Java Example
Need nothing.
[edit] How to Run this Java Example Program
We recommend running this Java example program with Eclipse.
For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.
It's fairly easy.
[edit] Question & Answer
Any question?
Click edit and post your question or answer here.
