We break down why copying “byte by byte” via
read()/
write() is usually slow, how “our” buffer
ByteArray differs from wrappers like
BufferedInputStream/
BufferedOutputStream, what the contract of
read(buffer) is (the
n value and
-1 on EOF), and what the canonical chunk-copy loop with
output.write(buffer, 0, n) looks like. At the end: choosing a buffer size, a data flow diagram (mermaid), and common mistakes.