// Collection of code snippets by Arne VajhÃ¸j 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;

public class PropsFun {
    private static final String PROPS_FILE = "C:\\test.props";
    public static void main(String[] args) throws IOException {
        Properties p = new Properties();
        System.out.println("Read props file");
        InputStream is = new FileInputStream(PROPS_FILE);
        p.load(is);
        is.close();
        System.out.println("Get value of k1");
        System.out.println("k1=" + p.get("k1"));
        System.out.println("Change value of k1");
        p.put("k1", "nogetandet");
        System.out.println("Write props file");
        OutputStream os = new FileOutputStream(PROPS_FILE);
        p.store(os, "Ændret som demo");
        os.close();
    }
}
