code: public static String decodeString(byte[] buf, int ofs, int len) throws CharacterCodingException {
          if (ofs < 0 || len < 0 || ofs + len < 0 || ofs + len > buf.length) {
              throw new IndexOutOfBoundsException();
          }
  
          CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder().onMalformedInput(CodingErrorAction.REPORT)
                  .onUnmappableCharacter(CodingErrorAction.REPORT);
          return decoder.decode(ByteBuffer.wrap(buf, ofs, len)).toString();
      }
docs: Decodes UTF-8 string from the given buffer.
  
  @param buf
  the buffer.
  @param ofs
  offset of the UTF-8 data in the buffer.
  @param len
  length of the UTF-8 data to decode.
  
  @return The decoded string.
  @throws CharacterCodingException
  when the specified data is not in valid UTF-8 format.