For those to whom it might be useful, here is the wrapper cfc I used for 
java.io.FileWriter which, in the application I was concerned with, attained a 
10x performance improvement over <cffile action='append'...> under condition 
that over 20,000 lines needed to be written out to a text file.
It aint nuthin special, but might save someone a few minutes...


<cfcomponent  displayname="javaFile" output="true">

        <cffunction name="initFile" returntype="boolean" access="remote" 
output="Yes">
                <cfargument name="filename" type="string" required="yes">
                <cfset var retValue=false>
                <cfif not(fileexists(arguments.filename))>
                        <cffile action="write" file="#arguments.filename#" 
output="">
                </cfif>
                <cfset this.FileObject = createobject("java",  
"java.io.FileWriter").init(arguments.filename, true)> 
                <cfset retValue=true>
                <cfreturn retValue>
        </cffunction>
        
        <cffunction name="appendRaw" returntype="boolean" access="remote" 
output="yes">
                <cfargument name="fileData" type="string" required="yes">
                <cfset var retValue=false>
                <cfset this.FileObject.write(arguments.fileData,0, 
len(arguments.fileData))>
                <cfset retValue=true>
                <cfreturn retValue>
        </cffunction>
        
        <cffunction name="appendLine" returntype="boolean" access="remote" 
output="yes">
                <cfargument name="fileData" type="string" required="yes">
                <cfset var retValue=false>
                <cfset var CrLf = chr(13) & chr(10)>
                <cfset var opbuffer=arguments.filedata & CrLf>
                <cfset this.FileObject.write(opbuffer,0,len(opbuffer))>
                <cfset retValue=true>
                <cfreturn retValue>
        </cffunction>
        
        <cffunction name="done" returntype="void" access="remote" output="yes">
                <cfset this.FileObject.flush()>
                <cfset this.FileObject.close()>
                <cfreturn>
        </cffunction>   

</cfcomponent> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338314
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to