I have a delimited file where each line is of a varying length and can have a varying amount of delimiters. I need to access a random line and replace it with a new line that may be shorter or longer in length. Because the file is large (20MB+), I need to do this as efficiently as possible.
I started with trying to write a simple program that would take a line number, a
string, and a file, move to the designated line number, and replace the existing line with the new string. I wanted to scan through the file and after n number of end line characters were reached, write the string after that position.
For example, the program below is supposed to take a file like this:
and change it to this:
The output of my program is below. As you can see, I can't even seem to get a char to read properly. What am I doing wrong?
Path=F:\Eclipse\Workspace\FlashCards\test.txt
Char at 0=?
Char at 2=?
.
.
.
Char at 28=?
Char at 30=?
Reached EOF!
Line 1 File Position=0
Done