Whatever message this page gives is out now! Go check it out!
getPropertyString(String filePath, String key, String encoding)Parameter | Required | Type | Description |
filePath | Yes | String | The absolute path of the properties file. |
key | Yes | String | A key defined in the properties file. |
encoding | No | String | The encoding of the properties file. The default is UTF-8. |
<cfscript>
path =GetDirectoryFromPath(GetCurrentTemplatePath()) & "test.properties"
property1=getPropertyString(path,"appname");
property2=getPropertyString(path,"port");
property3=getPropertyString(path,"smtpserver");
writeDump(property1)
writeDump(property2)
writeDump(property3)
</cfscript><cfscript>
path =GetDirectoryFromPath(GetCurrentTemplatePath()) & "test.properties"
property1=getPropertyString(path,"app.name","UTF-8");
property2=getPropertyString(path,"port","UTF-8");
property3=getPropertyString(path,"smtp.server","UTF-8");
writeDump(property1)
writeDump(property2)
writeDump(property3)
</cfscript><cfscript>
//Empty Key
try {
path = GetDirectoryFromPath(GetCurrentTemplatePath()) & "test.properties";
// Ensure that the function getPropertyString is defined or imported properly
property1 = getPropertyString(path,"");
}
catch (any e) {
writeOutput(e.message);
}
</cfscript><cfscript>
//key not present or invalid key
try {
path = GetDirectoryFromPath(GetCurrentTemplatePath()) & "test.properties";
// Ensure that the function getPropertyString is defined or imported properly
property1 = getPropertyString(path,"invalid.name");
writeDump(property1)
}
catch (any e) {
writeOutput(e.message);
}
</cfscript>