Here you can find the source of getUnicodeString(byte[] d, int length, int pos)
Parameter | Description |
---|---|
pos | The start position of the string |
length | The number of characters to be converted into a string |
d | The byte data |
public static String getUnicodeString(byte[] d, int length, int pos)
//package com.java2s; /*/*from www .j a v a 2s . c om*/ * Copyright (c) 2007-2016 AREasy Runtime * * This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed Software"); * you can redistribute it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ import java.io.UnsupportedEncodingException; public class Main { public static String UNICODE_ENCODING = "UnicodeLittle"; /** * Gets a string from the data array * * @param pos The start position of the string * @param length The number of characters to be converted into a string * @param d The byte data * @return the string built up from the unicode characters */ public static String getUnicodeString(byte[] d, int length, int pos) { try { byte[] b = new byte[length * 2]; System.arraycopy(d, pos, b, 0, length * 2); return new String(b, UNICODE_ENCODING); } catch (UnsupportedEncodingException e) { // Fail silently return ""; } } }