java - Write .properties file with coldfusion -


Has anyone already made this? Because it is possible to use JavaRB cfc created by MR. Paul Hastings, but it gives the possibility of reading from a property file, no one to write in it?

You can use the built-in Java property class to do this easily:

  & lt; Cfscript & gt; Fos = CreateObject ("java", "java.io.fileOutputStream"). Init (extension path ("out.properties"); Prop = Create Object ("Java", "Java." Properties); Props.setProperty ('site' "stackoverflow.com '); Props.setProperty ("for", "stephan"); Props.store (fos, "This is a property file saved from CF"); & Lt; / Cfscript & gt;   

However the format file format is very easy, so you can also use the ColdFusion file function to write properties file:

  & lt ; Cfscript & gt; Theater content = {"site" = "stackoverflow.com", "for" = "stephen"}; CRLF = CRR (13) & amp; Chr (10); Propfile = Open file (expand text ("out2.properties"), "write"); FileWrite (proffile, "## This is a property file saved from CF" & amp; cf); (Sahara in Sahara) {FileWrite (Profile, Prop & amp; amp;; Sahara [Sahara] & File Close (profile); & lt; / Cfscript & gt;   

This probably comes down where you have data stored, if it is in a structure, using CF can be easy, if it is the object of the Java properties , The code above is too low

Comments