public String (byte[] bytes, int offset, int length, Charset charset)

Constructs a new String by decoding the specified subarray 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 subarray.

This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required.

bytes     The bytes to be decoded into characters
offset     The index of the first byte to decode
length     The number of bytes to decode
charset     The charset to be used to decode the bytes

IndexOutOfBoundsException     If the offset and length arguments index characters outside the bounds of the bytes array

Since:  1.6