ColdFusion CFFile vs. Java java.io.BufferedOutputStream

<!---
	Test the standard ColdFusion CFFile and Java
	StringBuffer methodolog.
--->
<cftimer label="StringBuffer Test" type="outline">
 
	<!---
		Kill extra output. We want to do this because otherwise,
		we are creating [intIterations] amount of white space
		on the page. No need for that.
	--->
	<cfsilent>
 
		<!--- Get the file name to write to. --->
		<cfset strFilePath = ExpandPath( "./sb_output.txt" ) />
 
		<!--- Create a string buffer. --->
		<cfset sbOutput = CreateObject(
			"java",
			"java.lang.StringBuffer"
			).Init() />
 
		<!---
			Loop over tthe iterations to build up the string
			buffer. For each iteration, we are going to
			select a random string and add it to the buffer.
		--->
		<cfloop
			index="intI"
			from="1"
			to="#intIterations#"
			step="1">
 
			<!--- Add a random string to the string buffer. --->
			<cfset sbOutput.Append(
				"I am crazy about " &
				arrParts[ RandRange( 1, 7 ) ] &
				Chr( 13) & Chr( 10 )
				) />
 
		</cfloop>
 
		<!---
			Now that we have created the string buffer, write
			the data to selected file name.
		--->
		<cffile
			action="WRITE"
			file="#strFilePath#"
			output="#sbOutput.ToString()#"
			/>
 
	</cfsilent>
 
	<!--- Output name of file. --->
	#strFilePath#
 
</cftimer>

For Cut-and-Paste