I am currently trying to delete lines of a file in java?

Read the file, writing it to a new file at the same time, and omit what should be deleted. Then rename the old file to a different name. rename the new file to the old name, then, if all of that is successful, delete the old file.