A question was posted on the cf-talk list (thread) about reading large files with CFFILE and problems they were having.
I suggested trying java to read the large file line by line and I posted the following code:
<cfsetting showdebugoutput="Yes">
<cfscript>
cnt = 0;
// large text file, 4MB, 80,000+ lines
srcFile = "E:\Inetpub\wwwroot\tools\mass_email\list.dat";
// create a FileReader object
fr = createObject("java","java.io.FileReader");
// Call the constructure with the source file path
fr.init(srcFile);
// create a BufferedReader object
br = createObject("java","java.io.BufferedReader");
// call the constructor with the FileReader as the arg
br.init(fr);
// read the first line
str = br.readLine();
// loop ... str will be undefined if there are no more lines
while (isDefined("str")) {
// do stuff with the string
cnt = cnt + 1;
// read the next line so we can continue the loop
str = br.readLine();
}
// close the buffered reader object
br.close();
writeOutput(cnt);
</cfscript>
The code above was tested on CFMX 7 and it does work. On my server, it consistently returns the results in about 400ms (ranging between 350ms and 500ms).
In order to compare, I wrote some CFML code that does essentially the same thing using CFFILE and looping through the file content as a list with chr(10) as the delimiter.
The CFFILE route was slower and much more erratic, ranging from 450ms to over 2000ms - probably averaging 1400ms in the 20-30 times I reloaded the page.
So if you're reading a large file and doing line by line processing - consider using native java rather than CFFILE.