How do I convert a String from Unicode to another encoding and vice versa?

The basic answer is to use one of the two String constructors that use an encoding argument: String(byte[] bytes, int offset, int length, String enc) or String(byte[] bytes, String enc). Because the encoding is internal and, generally, an encoding translation takes place when writing to most output devices/peripherals/streams, it is difficult to show the results directly.
I have included some code that indirectly, via getBytes(String enc), attempts to show what happens using UTF-16 ( Big Endian Unicode, ) the platform default encoding and UTF-8. The base String contains "Enc" plus the Japanese ideograph "go" or 5. In all cases, on English NT 4.0, the string prints as "Enc?" - with the famous question mark, but the actual byte variation is shown except in the platform default case where 3F ( = '?' ) displays. You can easily change the String contents and encodings to determine other outputs on your platform. See: character encoding and Supported Encodings. Note that only a few encodings are supported if you don't have the international version of the JDK/JRE.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.