Sometimes, properties are stored in a file and you have to initialize property object from that file. Following code does exactly that:


Java Code:
import java.io.FileInputStream;
import java.util.Properties;

class PropertiesTest {
    public static void main(String args[]) {
	try {
		// set up new properties object from file "myProperties.txt"
	    FileInputStream propFile = new FileInputStream("myProperties.txt");
	    Properties p = new Properties(System.getProperties());
	    p.load(propFile);

		// set the system properties
            System.setProperties(p);
            System.getProperties().list(System.out);
	} catch (java.io.FileNotFoundException e) {
	    ;
	} catch (java.io.IOException e) {
	    ;
	}
    }
}