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 the lineReader instance hits the end of the file, readLine()
returns a result that causes thisLine to become undefined in the eyes of
CF)


-joe

-----Original Message-----
From: Dick Applebaum [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 16, 2004 9:22 AM
To: CF-Talk
Subject: Resolved: Out of Memory Error Transforming large XML
file.


Responding to my own message.

Lakers were trounced -- Boo!

Frustrated that I couldn't manipulate a large XML file in CFMX,
I  
decided to write a Java program to read a text file, line by
line.

Didn't need to --- found one by  Daryl Banttari, at:

http://www.macromedia.com/devnet/server_archive/articles/
leveraging_java_classes_cf.html

This works fine -- takes about 3 seconds to read the 3.8 meg,
85,000  
line file.

Interesting!

1) If it is so easy, why not implement it CFML?  -- the
CFMX/Java  
hybrid solution means extra work when you install or maintain
the app  
-- you have to deal with Java source and class files.

2) The routine points out another deficiency in CFML (or at
least  
CFML's interface to other languages, like Java) -- CFML cannot  
represent/recognize a Null!  The programmer had to provide a  
work-around.

Don't get me wrong, I am happy to find a solution, and being
able to  
interface Java is great!

But, IMO, this should not be necessary (to read a large file,  
line-by-line) for a language as rich and powerful as CFML!

Dick

On Jun 15, 2004, at 9:08 PM, Dick Applebaum wrote:
>

>  OK!
>
>  1) I can't readLn a file in CF so I read the entire 3.8 meg
xml file
>  into RAM
>
>  2) XmlTransform runs out of memory. so I can't use xls to
manipulate
>  the file
>
>  3) XmlSearch runs out of memory so I can't use Xpath to
manipulate the
>  file
>
>  4) I can CFexecute a Perl program to parse/render the file in
3-4
>  seconds
>
>  5) I can convert the 3,8 Meg, 85,000 line file to an
in-memory array
>  (Now I have the orig file and the array representation of
this file in
>  memory at the same time..
>
>  6) Now, I can line-by-line (array-element-by-array-element)
process
>  this file.
>
>  What's wrong with this picture --- AFAICT -- everything!
>
>  CF is the wrong tool!
>
>  Thought I'd never say that!
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to