I\'ve never had close experiences with Java IO API before and I\'m really frustrated now. I find it hard to believe how strange and complex it is and how hard it could be to
Start with a RandomAccessFile
and use read
or readFully
to get a byte array between pos1
and pos2
. Let's say that we've stored the data read in a variable named rawBytes
.
Then create your BufferedReader
using
new BufferedReader(new InputStreamReader(new ByteArrayInputStream(rawBytes)))
Then you can call readLine
on the BufferedReader
.
Caveat: this probably uses more memory than if you could make the BufferedReader
seek to the right location itself, because it preloads everything into memory.