Whatever message this page gives is out now! Go check it out!

SetPropertyString

Last update:
May 18, 2026

Description

Adds a list or collection of key-value pairs to the specified properties file. If the file is not present, the file will be created.

Returns

None

Syntax

setPropertyString(String filePath, String key, Object value, String encoding)

History

  • ColdFusion (2025 release): Added the function

Parameters

Parameter
Required
Type
Description
filePath
Yes
String
The absolute path of the properties file.
key
Yes
String
The key to add in the properties file.
value
No
Any object
The value for the specified key to be added in the properties file.
encoding
No
String
The encoding of the properties file. The default is UTF-8. If not specified, picks the default encoding.

Example

<cfscript>
    //setPropertyString with key and value
    path =GetDirectoryFromPath(GetCurrentTemplatePath()) & "config.properties"
    setPropertyString(path,"host","localhost","utf-8");
    property1=getPropertyString(path,"host");
    if (property1 EQ "localhost") {
        writeOutput("Successfully set key");
    } 
    else {
        writeOutput("Failed to set key");
    }
</cfscript>

Output

Successfully set key

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page