Sets one key, or several keys from a struct, in a Java properties file. Existing keys are updated, new keys are added, and other keys are kept. The file is rewritten with a #File created by CF comment and a timestamp at the top.
setPropertyString(filepath, key, value [, encoding])
setPropertyString(filepath, properties)
→ returns void
properties struct.
key.
utf-8key and value.
key and value syntax, not the properties struct.
path = getTempDirectory() & "app.properties";
fileWrite(path, "a=1");
setPropertyString(path, "b", "hello");
writeOutput(getPropertyString(path, "b"));
Expected Result: hello
path = getTempDirectory() & "app.properties";
fileWrite(path, "a=1");
setPropertyString(path, {"a": "9", "c": "3"});
writeOutput(serializeJSON(getPropertyFile(path)));
Expected Result: {"a":"9","c":"3"}
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.