I’m working with a really really big file. I’m talking about gigabyte big.
I need to be able to read a line from a particular index as the textfile is consistently being updated. What is the fastest possible solution for achieving this? I am not constrained by space requirement at all.
Edit: More detailed info posted. Suppose I have the following text that needs to be read:
Jun 21 09:47:53 ez-x5 user.debug if_comm: [TX] 30 40 05
Jun 21 09:47:53 ez-x5 user.debug if_comm: [RX] 04
Jun 21 09:47:53 ez-x5 user.debug if_comm: [TX] 30 40 05
Jun 21 09:47:54 ez-x5 user.debug if_comm: [RX] 02 30 40 0f 30 32 31 23 64 31 30 32 30 64 64 49 49 49 49 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 03 0b
This textfile is consistently updated by our logger. When the text file gets updated, I need to read the new line (separated by \n) of whatever is appended to the log.
With a FileStream object you can get random access in the file by changing the Position property.
See here.
When setting the Position it seeks to the position in the stream, so you will need to know ahead of time about where in the file you want to start looking from.