Delete a line from a file in java
Posted
by dalton conley
on Stack Overflow
See other posts from Stack Overflow
or by dalton conley
Published on 2010-03-18T16:01:35Z
Indexed on
2010/03/18
16:51 UTC
Read the original article
Hit count: 437
Ok, so I'm trying to delete lines from a text file with java. Currently the way I'm doing this, is I'm keep track of a line number and inputting an index. The index is the line I want deleted. So each time I read a new line of data I increment the line count. Now when I reach the line count that is the same index, I dont write the data to the temporary file. Now this works, but what if for example I'm working with huge files and I have to worry about memory restraints. How can I do this with.. file markers? For example.. place the file marker on the line I want to do delete. Then delete that line? Or is that just too much work?
© Stack Overflow or respective owner