I have a .txt
file, which I want to process in Java. I want to delete its last line.
I need ideas on how to achieve this without having to copy the entire content into another file and ignoring the last line. Any suggestions?
You could find the beginning of the last line by scanning the file and then truncate it using FileChannel.truncate
or RandomAccessFile.setLength
.