Discussion Topic 3
Complexity of ways of reading files
In this
unit we have described how a Java program could read a text file one line at a time
this required four classes. We have also described how a text file can be read as if it
were an array of bytes, where any byte can be read at any position this requires
only one class: RandomAccessFile.
The job
done by RandomAccessFile seems on the surface
to be more complicated.
Why do we need four classes
to read a text file one line at a time, but only one class to read it like a byte array?