Working with really large files in CFML

I needed to parse the usage log file of my showTweets plugin. I got a bit scary, because the bloody thing was over 800 megabytes in size!
As a logical solution, I thought of using <cfloop file="x" />, because that way not the whole file needs to be read into memory. But when I ran the code, it crashed anyway with an outOfMemory error :-(

I just recently learned about how the Java Virtual Machine and Railo...

No Comments

Railo tip: relative file paths in cfdirectory, cffile, etcetera

Railo has so many cool features that we don't all know about! I am a pretty lazy programmer, so if I can save some typing, I love it.

When writing a file to the directory of the current executing cfm template, I normally had to do something like

<cffile action="write" file="#GetDirectoryFromPath(GetCurrentTemplatePath())#somefile.txt" output="hello world" />

But with Railo, you can use relative paths:

<cffile action="write" file="somefile.txt" output="hello world" />

And that's not just with files:

<cfdirectory action="list" directory="." name="qFiles" />
<cfset x = fileRead('mylocalfile.txt') />
<cfset x = fileRead('../mylocalfile.txt') />
#fileExists('myfile.txt')#
#directoryCreate('newdirectory')#

It's so logical, and it works perfectly. +1.000 for Railo!

No Comments

CF function generate3DesKey, v1.1

Adobe Coldfusion already had this function built-in, without any documentation.

Now it is here for all CFML developers:

<cffunction name="generate3DesKey" output="no">
<cfargument name="fromstring" type="string" required="no" />
<cfif not structKeyExists(arguments, "fromString")>
<cfreturn generateSecretKey('DESEDE') />
</cfif>
<cfset var secretKeySpec = createObject("java", "javax.crypto.spec.SecretKeySpec").init(arguments.fromstring.getBytes(), "DESede") />
<cfreturn toBase64(SecretKeySpec.getEncoded()) />
</cffunction>

Updated, with thanks to Jason Dean :-)

2 Comments

Certified, so time to change my site!

Since I got my certification as a Railo Certified System Administrator yesterday, I thought now is the time...

Coldfusiondeveloper.nl becomes RailoDeveloper.com!

I am proud of the product, and know how to handle it in-depth, so that's what I'll be blogging about from now on :-)

Bye-bye Coldfusion, and a happy happy welcome to Railo!

4 Comments

My first own CFML tag: <cfhoneypot>

If you are a CFML (Coldfusion) programmer like me, you know the power of all those <cf...> tags which we use everyday. Every new release of Adobe Coldfusion gives us new tags, after which the opensource engines like Railo include them in their products a.s.a.p.
But did you know that you can also create your own <cf...> tags with Railo? And that they can be written in CFML? Difficult? No, not at all!

1 Comment