Reputation: 1175
Let's say I have the word "Sample". In UTF-16 BE, this is represented as 00 53 00 61 00 6D 00 70 00 6C 00 65
. When I have this, I would like to convert it back to "Sample" using Java. How do I do this?
Upvotes: 0
Views: 2024
Reputation: 272207
You can convert a byte sequence to a String with a specified charset using new String(array, charset)
Constructs a new String by decoding the specified array of bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array.
Upvotes: 5