-2

I'm attempting to figure out how to read a text file and delete the first line with a java program. For example, if I have a text file containing:

07:00 "Wake up"
12:00 "Lunch time"
16:00 "Done with class"
18:00 "Dinner time"
20:00 "Homework time"
22:00 "Bed time"

what I would like to do is to read the first line, and then enter a block of code that will schedule a task (the task will be to output the "" at the given time).

What I'm stuck on is how to destructively read in the first line. I need to change the above text block after execution, turning it into:

12:00 "Lunch time"
16:00 "Done with class"
18:00 "Dinner time"
20:00 "Homework time"
22:00 "Bed time"

I've searched around online, however most pages tout how they can do this non-destructively (objectively better, but worse in my specific case).

DVK
  • 126,886
  • 32
  • 213
  • 327

1 Answers1

0

This has to be done non-destructively at first, because you have to load a copy of the file into memory, remove the line.

The line isn't destroyed in the original file on disk until you write the block of text (without the 1st line) back to the file.

Bill
  • 329
  • 2
  • 2