I need to use Java to read, parse and process a fixed length text file. The
data fields are fixed, such that field1 starts at 0 and is N bytes long,
field2 starts at 20 and is N bytes long, etc. etc. Some fields are long and
will span multiple rows. There could even be breaks in the file where a few
lines are skipped.
What's the best way to approach this with Java? Is there an I/O class that
works best for this, or better yet, is specifically designed to work with
fixed length text files?
Thanks in advance for any advice.
Julian
On Mon, 7 Nov 2005 20:34:55 -0500, "Julian McMaster"
<fideliteus@yahoo.com> wrote, quoted or indirectly quoted someone who
said :
>What's the best way to approach this with Java? Is there an I/O class that
>works best for this, or better yet, is specifically designed to work with
>fixed length text files?
Most easily you can forget the fixed lengthness of it and read it a
line at a time then split the line into pieces with substring.
See http://mindprod.com/applets/fileio.html
tell it you have character data encoded. I trust you know the
encoding.
You could also read it a field at a time using a BufferedReader.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.