1Z0-829 Java I/O API and Securing Applications Practice Question
Given a requirement to efficiently copy a large file (over 2 GB) from one path to another, which approach is most appropriate for Java NIO.2?
⚠ Common exam trap
Many candidates assume `Files.copy()` is the most straightforward and efficient NIO.2 method, but the exam specifically tests knowledge of zero-copy APIs (`FileChannel.transferTo()`) for large file operations, where the overhead of stream-based copying becomes a performance bottleneck.
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
✓
Using FileChannel.transferTo() with position and count
`FileChannel.transferTo()` leverages zero-copy I/O, which allows data to be transferred directly between file system caches without unnecessary copying through user-space buffers. This is particularly efficient for large files (over 2 GB) as it minimizes context switches and memory overhead, and the method supports a `position` and `count` parameter to handle large file offsets correctly.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING)
Why it's wrong here
Files.copy is efficient but may not be as performant as direct channel transfer for very large files.
- ✗
Using Files.readAllBytes() then Files.write()
Why it's wrong here
ReadAllBytes loads the entire file into memory, which is not feasible for a 2 GB file.
- ✗
Using FileInputStream and FileOutputStream with a buffer of 8192 bytes
Why it's wrong here
Traditional stream copying with a small buffer is inefficient for large files.
- ✓
Using FileChannel.transferTo() with position and count
Why this is correct
FileChannel.transferTo() leverages OS-level file transfer mechanisms, making it most efficient for large files.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.