Courseiva
Java I/O API and Securing ApplicationshardMultiple ChoiceObjective-mapped

1Z0-829 Java I/O API and Securing Applications Practice Question

A Java application uses FileChannel to copy a file to a remote network drive. The developer wants to ensure atomic file replacement on the destination. Which approach is correct?

⚠ Common exam trap

Many candidates assume `Files.copy()` with `REPLACE_EXISTING` or `FileChannel.transferTo()` provides atomicity because they replace the destination, but neither guarantees that the replacement is atomic — only `ATOMIC_MOVE` ensures the entire operation is indivisible at the file system level.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Use Files.move() with StandardCopyOption.ATOMIC_MOVE.

`Files.move()` with `StandardCopyOption.ATOMIC_MOVE` guarantees that the file replacement on the destination file system is atomic — either the entire move succeeds or the original state remains intact. This is essential for remote network drives where partial writes or concurrent access could leave the destination in an inconsistent state. The `ATOMIC_MOVE` option leverages file system–level atomic rename operations (e.g., NFS or SMB support) to ensure no intermediate state is visible.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Delete the destination file, then rename the temporary file.

    Why it's wrong here

    Not atomic; another process may see missing file.

  • Use Files.move() with StandardCopyOption.ATOMIC_MOVE.

    Why this is correct

    Requests atomic move; throws exception if not supported.

  • Use FileChannel.transferTo() to write directly.

    Why it's wrong here

    Transfers data but no atomicity guarantee.

  • Use Files.copy() with REPLACE_EXISTING option.

    Why it's wrong here

    Copy is not atomic; replace may happen mid-operation.

About these practice questions

Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.