We break down why the “default encoding” is a hidden dependency on the environment, and how to make I/O behavior reproducible: use an explicit
Charset and
Charsets
.
UTF_8, read and write text via
readText/
writeText, work with
ByteArray and manual decoding when needed, apply a streaming approach via
bufferedReader/
use, and also assemble a mini-API so the encoding remains a “single source of truth”. At the end, we cover typical mistakes when working with encodings.