Beispiel #1
0
  /*
   * Converts encoded \uxxxx to unicode chars and changes special saved
   * chars to their original forms
   *
   * @param s
   *            the  byte arrary needing convert.
   * @param offset
   *            the offset of byte arrary
   * @param lengthFlag
   *            Whether add one byte of length in the result.
   *            <code>true</code> add one byte of length in the result
   * @return  the convert result of the byte arrary.
   */
  public static String loadConvert(byte[] s, int offset, boolean lengthFlag)
      throws IllegalArgumentException {
    if (null == s || (offset + (lengthFlag ? 1 : 0)) > s.length)
      throw new IllegalArgumentException("invalid byte arrary");

    int len = (s.length - offset);

    if (lengthFlag) {
      len = s[offset] & 0xFF;
      offset++;
    }

    return UTF8Util.bytes2StringUTF8(s, offset, len, true);
  }