Mega Code Archive

 
Categories / Java Tutorial / Collections
 

Using Enumeration to loop through Properties

import java.util.Enumeration; import java.util.Properties; public class MainClass {   public static void main(String[] a) {     Properties props = System.getProperties();     Enumeration e = props.propertyNames();     while (e.hasMoreElements()) {       String key = (String) e.nextElement();       System.out.println(key + " -- " + props.getProperty(key));     }   } } java.runtime.name -- Java(TM) 2 Runtime Environment, Standard Edition sun.boot.library.path -- C:\Java_Dev\sdk\jdk\jre\bin java.vm.version -- 1.5.0-b64 java.vm.vendor -- Sun Microsystems Inc. java.vendor.url -- http://java.sun.com/