Is it possible to read the values of a java proper...
# lucee
h
Is it possible to read the values of a java properties file with native ColdFusion functionality instead of using java libraries? I guess we could do file read and listToArray with char(10) - but replacing the unicode entities and special characters could be tricky.
q
Many of the Java properties are exposed via the #server# variable.... Have you checked to see if what you are looking for is in there?
☝️ 1
b
@harryk I have a wrapper for this on ForgeBox
I used to use the Java class, but I switched to a pure CFML approach a while back so I could • preserve comments • preserve the order of the file when writing it back out
👍 1
This is a nice fluent approach that I use inside CommandBox and CFCOnfig. It also powers CommandBox's
propertFile
command namespace.
Copy code
getInstance( 'propertyFile' )
	.load( myPath )
	.set( 'myProp', 'myValue' )
	.set( 'myOtherProp', 'myOtherValue' )
	.store();
The object can be treated as a facade with a fluent API, and can also be treated directly as a struct since the properties themselves are exposed via the
this
scope.
Oh, this also powers the CommandBox dotenv module
h
Cool, thanks a lot! Will try it out