P
Paul.Lee.1971
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
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