<cfscript>
/**
* Reads a file.
*
* @param file The filename to read.
* @param from The line number specifying where to begin reading.
* @param to The line number specifying where to stop reading.
* @param NL Character to use for newlines. Defaults to Chr(13)Chr(10)
* @return Returns a string.
* @author Raymond Camden ([EMAIL PROTECTED])
* @version 1, December 3, 2001
*/
function FileRead(filename) {
var fileStr = "";
var fileReaderClass = createObject("java", "java.io.FileReader");
var fileReader = fileReaderClass.init(filename);
var lineNumberReaderClass =
createObject("java","java.io.LineNumberReader");
var lineReader = lineNumberReaderClass.init(fileReader);
var notDone = true;
var lastLine = 0;
var thisLine = 0;
var NL = Chr(13) & Chr(10);
var from = 0;
var to = 0;
var line = "";
//optional FROM
if(arrayLen(arguments) gt 1) from = arguments[2];
//optional TO
if(arrayLen(arguments) gt 2) to = arguments[3];
//optional NL
if(arrayLen(arguments) gt 3) NL = arguments[4];
if(not fileExists(filename)) return "";
while(notDone) {
line = lineReader.readLine();
thisLine = lineReader.getLineNumber();
if( (from is 0 OR thisLine gte from) AND (to is 0 OR
thisLine lte to)) fileStr = fileStr & line & NL;
if(thisLine is lastLine) notDone = false;
lastLine = thisLine;
}
return fileStr;
}
</cfscript>
At 03:47 PM 7/12/2004, you wrote:
>I see that Macromedia recommends not using CFFILE with large files such as
>log files because it reads the whole thing into memory. So, my question is -
>what are you supposed to do if you have to work with large files. I am
>surprised that there is no SEEK capability. Anyone agree that this should be
>in there? Or am I missing something?
>
>-Dustin Snell
>Network Automation, Inc
>
>----------
>[<http://www.houseoffusion.com/lists.cfm/link=t:4>Todays Threads]
>[<http://www.houseoffusion.com/lists.cfm/link=i:4:170163>This Message]
>[<http://www.houseoffusion.com/lists.cfm/link=s:4>Subscription]
>[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=905.825.4>Fast
> Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings]
>[<https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion&business=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick>Donations
>and Support]
>
>----------
><http://www.houseoffusion.com/banners/view.cfm?bannerid=36>
>b03929b.jpg
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

