如代碼所示
[java] view plain copy /** * */ package pkg; import java.util.Enumeration; import java.util.Iterator; import java.util.Map.Entry; import java.util.Properties; /** * @author qefee * */ public class ShowProperties { /** * @param args */ public static void main(String[] args) { Properties properties = System.getProperties(); // show keys showKeys(properties); // show values showValues(properties); // show keys and values showKeysAndValues(properties); } /** * @param properties */ private static void showKeys(Properties properties) { Enumeration<?> enu = properties.propertyNames(); while (enu.hasMoreElements()) { Object key = enu.nextElement(); System.out.println(key); } } /** * @param properties */ private static void showValues(Properties properties) { Enumeration<Object> enu = properties.elements(); while (enu.hasMoreElements()) { Object value = enu.nextElement(); System.out.println(value); } } /** * @param properties */ private static void showKeysAndValues(Properties properties) {