Before Java 18, the default charset was environment-dependent, meaning the Java Virtual Machine (JVM) chooses the default charset during start-up, based on the run-time environment, like the operating system, the user’s locale, and other factors. For example, on macOS, the default charset is UTF-8; on Windows, the default charset is ‘windows-1252’ (if English locale).
Since the default charset is not the same from machine to machine, APIs that use the default charset may cause unwanted behaviors or errors, especially the IO APIs like java.io.FileReader and java.io.FileWriter.