
Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Hi Roedy, thanks for responding,
> I am puzzled what you are doing there. readLine is something you do
> with sequential files not RandomAccess. You might with a
[quoted text clipped - 6 lines]
> I need to know more about your file structure and the problem you are
> trying to solve.
I have a pure Text file.
Node A has a one-to-many relationship with Node B, and Node B has a one
to many relationship with Node C. I first find Node A. All the Node B's
could be anywhere in the file. Once I find the first Node B, then I
find all the Node C's that can also be anywhere in the file.
Find Node A, save file pointer via RandomAccessFile.getFilePointer() ,
call RandomAccessFile.seek(0) and find all Node B's,
repeat for node C's . I'm using regex to get the Node values, and as
such I'm thinking I need a readline. I tried wrapping in BufferedReader
but it seemingly didn't like the seeks.
> Another possible sort of thing you can do is seek to a spot on in the
> randomaccess file, considered as a giant pool of bytes and read say
> 16K into into a byte[]. See http://mindprod.com/applets/fileio.html
> for how. Then set up a ByteArrayReader to read the chunk or the first
> bit of it, sequentially as chars or strings. Again see
> http://mindprod.com/applets/fileio.html for how to do that.
Could that work by splitting into a line, seperating by \n , and then
converting the bytes into a String? Or could I somehow parse a regex on
a ByteArray?
In the end, what I have works but is slow. My first idea is to do the
search in memory which should be faster then searching in a file.
Thanks,
iksrazal