Ray, here's the line reader that Joe Rinehart suggested (with a slight
mod).

Enjoy!

Dick

  Hey Joe

  Your No Class Reader Works Great!

  much faster than the other! (almost as fast as a cffile read of
  the
  entire file).

  I simplified the EOF test so I could use a While loop.

  Thanks

  Dick

  Here's the revised code:

  <cfsetting enableCFOutputOnly="yes" />
  <cfset lineCount = 0 />

  <cfset timer = GetTickCount() />

  <cfscript>
  ���filename = "/Users/Richard/Music/iTunes/iTunes Music Library.xml";
  ���fileReader = createObject("java", "java.io.FileReader");
  ���fileReader = fileReader.init(filename);
  ���lineReader = createObject("java","java.io.LineNumberReader");
  ���lineReader = lineReader.init(fileReader);

  ���thisLine = true;
  ���while (isDefined("thisLine")) {
  �����thisLine = lineReader.readLine();
  �����lineCount = LineCount + 1; // do any processing of the line here
  ���}

  </cfscript>

  <cfoutput>
  <br>count = #lineCount# | #GetTickCount() - timer#
  </cfoutput>
  <cfsetting enableCFOutputOnly="no" />

  I always forget to kill blank lines��on this sort of thing --
  very
  important

  On Jun 16, 2004, at 6:28 AM, Joe Rinehart wrote:

  > Hey Dick,
  >
  >��I've done a similar thing, but didn't create the external
  >��CFBufferedReader class. Do you see any reason why the
  following
  > wouldn't
  >��provide the same?
  >
  >��<cfscript>
  >��� filename = "c:\cfusionmx\wwwroot\lineNumberReader.cfm";
  >��fileReader = createObject("java", "java.io.FileReader");
  >��fileReader = fileReader.init(filename);
  >��lineReader = createObject("java","java.io.LineNumberReader");
  >��lineReader = lineReader.init(fileReader);
  >��</cfscript>
  >
  >��<cfset eof = false>
  >��<cfloop condition="not eof">
  >��� <cfset thisLine = lineReader.readLine()>
  >��� <cfif not isDefined("thisLine")>
  >������<cfset eof = true>
  >��� <cfelse>
  >������<cfoutput>#htmlEditFormat(thisLine)#<br></cfoutput>
  >��� </cfif>
  >��</cfloop>
  >
  >��(when��lineReader instance hits the end of the file,
  readLine()
  > returns
  >��a result that causes thisLine to become undefined in the eyes
  of��CF)
  >
  >��-joe
  >
  ��_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to