How can I delete a specific line (by index) from a text file with the class org.apache.commons.io.FileUtils
?
The index of the line to be deleted already know him, so I need some method that I delete a specific line from a file.
How can I delete a specific line (by index) from a text file with the class org.apache.commons.io.FileUtils
?
The index of the line to be deleted already know him, so I need some method that I delete a specific line from a file.
You can use lineIterator function of the same library.
fyi, Iterator loads lazily into memory and drops reference to previous line when next is called. [@Obicere : Also, I can not comment directly to the question but loading all the lines to memory does not like a good idea. ]