15.4.4 Updating Sequential-Access Files

The data in many sequential files cannot be modified without the risk of destroying other data in the file. For example, if the name “White” needs to be changed to “Worthington,” the old name cannot simply be overwritten, because the new name requires more space. The record for White was written to the file as

300 Pam White 0.00

If the record is rewritten beginning at the same location in the file using the new name, the record will be

300 Pam Worthington 0.00

The new record is larger (has more characters) than the original record. “Worthington” would overwrite the “0.00” in the current record and the characters beyond the second “o” in “Worthington” will overwrite the beginning of the next sequential ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.