Read text files one line at a time with ColdFusion
This is a pretty basic use of the how to capitalize on ColdFusion / Java, but I recently had to show someone else how to do this as well as use it myself today to parse a very large CSV file.
<cfscript>
var f = "";
var endOfFile = false;
f = createObject("java","java.io.FileReader").init(arguments.csvFileLocation);
f = createObject("java","java.io.BufferedReader").init(f);
while (NOT endOfFile) {
line = f.readLine();
if (NOT isDefined("line")) {
endOfFile = true;
break;
} else if (len(line)) {
// {LINE PARSING CODE HERE}
}
}
f.close();
</cfscript>
5 comments - Posted by Russell Brown at 11:38 AM - Categories: ColdFusion | Java | Development