Reading in chunks of data
- From: "Paul.Lee.1971@xxxxxxxxx" <Paul.Lee.1971@xxxxxxxxxxxxxx>
- Date: Thu, 10 Jul 2008 06:07:36 -0700 (PDT)
Hi,
I'm reading up on the use of the RandomAccessFile (and other file I/O)
classes in Java but I haven't found anything that can help me. Is
there any way to read in data structured in a text file, as follows:
Apr 10
"The Book of the Dead"
£17.95
Apr 13
"Unconvention Highlights"
£4.99
Apr 14
"Miserable Quotients"
£0.02
etc. etc.
So that I can do the following (in pseudo code):
read first three lines: first line assigned to date value, second to
book title, third to cost variable
read next three lines: first line assigned to date value, second to
book title, third to cost variable
etc.
The only other way I thought about doing it is to read in the file
line-by-line, but, by using line counting
and some arithmetic with modulo operators (?), know that the 1st, 4th,
7th lines are date values,
lines 2, 5 and 8 are titles etc., but this seems fiddly. There must be
an easy way to do this...
With best wishes
Paul
.
- Follow-Ups:
- Re: Reading in chunks of data
- From: Arved Sandstrom
- Re: Reading in chunks of data
- From: Eric Sosman
- Re: Reading in chunks of data
- Prev by Date: to get environment variables...
- Next by Date: Re: to get environment variables...
- Previous by thread: to get environment variables...
- Next by thread: Re: Reading in chunks of data
- Index(es):
Relevant Pages
|