As you guys may know, on one of my production boxes, I’ve been having CFMail issues. Details here.
Here is an image of the problem:

As well, I looked parsing the necessary cfmail files to get rid of defective line. But looking at ColdFusion and Java (and even .NET), nothing stood out.
So that was it! I needed a solid CFC to work with text files on a line by line basis. Enter FileByLine.CFC.
Here is some code!
<![CDATA[
<!---
Author: Sami Hoda
Email: sami bytestopshere.com
Blog: http://www.bytestopshere.com
Version: v0.1
Note: Comments appreciated!
Warning:
This code is provided as is.
I make no warranty or guarantee.
Use of this code is at your own risk.
READING OF LARGE FILES INTO ARRAYS FOR MANIPULATION CAN BE RISKY. RE-READ WARNING!
To Do:
- Optimization! I want it faster!
- Implement some sort of find capability... use Regex?
License:
Copyright 2009 Sami Hoda
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--->
]]>
And now the image shows:

Voila! Have fun. Comments welcome!
I’ll add this code to RiaForge shortly!
UPDATE: Code now on RiaForge, see http://filebyline.riaforge.org/.
Comments on: "Reading Text Files Through Line Number – A Solution" (6)
Would:
cat mailSpoolFileName|grep -v “${mailServer}”
or similar not be easier ?
Tom,
That would be a *Nix solution, no?
I wanted something generic I could use all over, not just for this cfmail issue as well.
UPDATE: Code now on RiaForge, see http://filebyline.riaforge.org/.
@Sami: No, not at all; cat, grep and friends are GNU tools, and available anywhere you can compile C
For instance, the Win32 versions are : http://gnuwin32.sourceforge.net/packages.html
Tom,
Hmmm. So in theory, I could write a CF scheduled task to go through each file in the Undelivr folder and run the cat command against it?
Aye.
I wouldn’t bother ColdFusion with this though, you can drive it all from a scheduled batch job.