package com.myapp.scjp6.staticimport;
import java.util.Properties;
import java.util.Set;
public class SystemProperties {
public static void main(String[] args) {
Properties props = System.getProperties(); // calling here .getProperties() on System class
Set properties = props.keySet();// all the entry of props because Properties is HashTable with //key value pair entry
for (Object object : properties) {//iterate over it
System.out.println(object);
String value =(String) props.get(object); // the the value for each entry
System.out.println(value);
}
props.setProperty("appName", "myApp"); // (2)// adding new key value to java property
String value = props.getProperty("appName"); // (3)//fetching the value for key that is added by //us
System.out.printf("%s=%s%n","appName", value);
}
}
import java.util.Properties;
import java.util.Set;
public class SystemProperties {
public static void main(String[] args) {
Properties props = System.getProperties(); // calling here .getProperties() on System class
Set properties = props.keySet();// all the entry of props because Properties is HashTable with //key value pair entry
for (Object object : properties) {//iterate over it
System.out.println(object);
String value =(String) props.get(object); // the the value for each entry
System.out.println(value);
}
props.setProperty("appName", "myApp"); // (2)// adding new key value to java property
String value = props.getProperty("appName"); // (3)//fetching the value for key that is added by //us
System.out.printf("%s=%s%n","appName", value);
}
}