Your application needs to write user data into a file. To ensure data consistency, even if the application crashes during a write operation, what measure would you take?

  • Enable automatic file versioning to track changes and ensure consistency.
  • Use a try-except block to handle crashes and continue writing.
  • Use file locking to prevent other processes from accessing the file during writes.
  • Write data to a temporary file and then replace the original file.
To ensure data consistency, write data to a temporary file first, and then replace the original file. This way, if the application crashes during writing, the original file remains intact.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *