Sounds like you need a Java class that is guaranteed to fully write out
its changes before it can be used for another write to the same file. I
wrote up a quick Java class that should do that, which is below.

import java.io.FileWriter;
import java.io.IOException;

public class FileAppender {
private static FileWriter writer = null;

public FileAppender(String filename) throws IOException {
writer = new FileWriter(filename, true);
}

public void write(String value) throws IOException {
synchronized(writer) {
writer.write(value);
writer.flush();
}
}

public void close() throws IOException {
writer.close();
}
}

To use this from CF, do the following.

<cfscript>
appender = CreateObject("java", "FileAppender");
appender.init("path/to/filename/here");

for(itr = 1; itr lte queryname.RecordCount; itr = itr + 1)
appender.write(queryname.somecolumn[itr]);

appender.close();
</cfscript>

Matt Liotta
President & CEO
Montara Software, Inc.
http://www.MontaraSoftware.com
(888) 408-0900 x901

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to