Java – written in ColdFusion Properties file
•
Java
Has anyone done this?
Solution
You can easily do this using the underlying Java properties class:
<cfscript> fos = CreateObject("java","java.io.FileOutputStream").init(ExpandPath("out.properties")); props = CreateObject("java","java.util.Properties"); props.setProperty("site","stackoverflow.com"); props.setProperty("for","Stephane"); props.store(fos,"This is a properties file saved from CF"); </cfscript>
Although the format of the property file is very simple, you can also use the ColdFusion file function to write the property file:
<cfscript> props={"site"="stackoverflow.com","for"="Stephane"}; crlf=chr(13) & chr(10); propFile = FileOpen(ExpandPath("out2.properties"),"write"); FileWrite(propFile,"##This is a properties file saved from CF" & crlf ); for(prop in props){ FileWrite(propFile,prop & "=" & props[prop] & crlf); } FileClose(propFile); </cfscript>
It probably boils down to where you store your data If it is in the structure, it may be easier to use CF If it is in a Java properties object, the above code is very small
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码