A character encoding or charset specifies the binary representation of the coded character set. Every instance of the Java virtual machine (JVM) has a default charset, which may or may not be one of the standard charsets. The default charset is determined during virtual-machine startup and typically depends upon the locale and charset being used by the underlying operating system [API 2014]. The default character encoding that can be set at startup time, for example:
java -Dfile.encoding=UTF-8 … com.x.Main
...
This compliant solution explicitly specifies the character encoding used to create the output the string (in this example, UTF-16LE
) as the second argument to the String
constructor. The LE form of UTF-16 uses little-endian byte serialization (least significant byte first). Provided that the character data was encoded in UTF-16LE
, it will decode correctly.
...