macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

filewriter.cfc

Subject: filewriter.cfc
From: Steve
Date: Fri, 30 Nov 2007 15:10:06 -0800 PST
Newsgroups: macromedia.coldfusion.advanced_techniques

I started to play around with filewriter.cfc today (http://
www.informationsavvy.com/coldfusion/) and I'm stuck on one minor
point.

I can't figure out how to specify the output directory of where the
file will be written to.

By default, it's written to {CF8 Directory}\runtime\bin\

With my limited CFC and even more limited java skills, I'm having a
hard time either creating a new variable to pass to the function that
specifies a path to write to:

--- original code ---
<cfargument name="fileName" type="string" required="Yes" hint="the
path and name of the file to write" />
<cfargument name="fileEncoding" type="string" required="yes" hint="the
file encoding" />
<cfargument name="bufferSize" type="numeric" required="no"
default="8192" hint="the buffer size for the bufferedWriter" />

<cfscript>
arguments.fileName = trim(arguments.fileName);
arguments.fileEncoding = uCase(trim(arguments.fileEncoding));
arguments.bufferSize = bufferSizeLimit(arguments.bufferSize);

variables.joFileOutputStream =
CreateObject('java','java.io.FileOutputStream').init(javaCast('string',
arguments.fileName));

getFileEncoding(arguments.fileEncoding);

variables.joOutputStreamWriter =
CreateObject('java','java.io.OutputStreamWriter').init(variables.joFileOutputStream,
javaCast('string',
arguments.fileEncoding));

variables.joBufferedWriter =
CreateObject('java','java.io.BufferedWriter').init(variables.joOutputStreamWriter,
javaCast('int', arguments.bufferSize));
</cfscript>

I was thinking about adding an variables.strFilePath with an
ExpandPath in it before the cfscript, but I lack the knowledge if a)
this will work and b) where to add it in the cfscript that creates the
java object

Thanks



<Prev in Thread] Current Thread [Next in Thread>