Hey guys
Im wanting to read in from a directory of files and take each file in turn checking for a specific word. Once have have found this word i want to replace it.
I've got a solution but its not really that efficent. It reads all the content of the file and stores it in an array, logs where the word matched then prints everything back out chaning the lines as it finds them.
There's got to be a way I can write to a specific line in a text file?
heres an example
Search for dog:
Read first file from directory
look for line to replace
write over this line
continue searching file for other matches
if no matches move to next file in directory.
Basically all i want to know is if it is possible to replace a specific line in a text file without reading in everything then writing it all out.
thanks in advance
andy
Im wanting to read in from a directory of files and take each file in turn checking for a specific word. Once have have found this word i want to replace it.
I've got a solution but its not really that efficent. It reads all the content of the file and stores it in an array, logs where the word matched then prints everything back out chaning the lines as it finds them.
There's got to be a way I can write to a specific line in a text file?
heres an example
Search for dog:
Read first file from directory
look for line to replace
write over this line
continue searching file for other matches
if no matches move to next file in directory.
Basically all i want to know is if it is possible to replace a specific line in a text file without reading in everything then writing it all out.
thanks in advance
andy