List of utility methods to do Byte Array to String Convert
String | bytes2StringPtr(byte[] data, String type) bytes String Ptr if (type == null) { type = ""; StringBuffer sb = new StringBuffer(); System.out.println(); for (int i = 0; i < data.length; i++) { sb.append(String.format("".equals(type) ? "0x%x," : type + ",", data[i])); ... |
String | getString(byte[] bb) get String return new String(bb); |
String | getString(byte[] bytes) get String return getString(bytes, "GBK"); |
String | getString(byte[] bytes, String charsetName) get String return new String(bytes, Charset.forName(charsetName)); |
String | getString(byte[] fromBytes, int offset, int length) get String final String toString; try { toString = new String(fromBytes, offset, length, BYTE_CHARSET); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); return toString; |
String | getString(byte[] originalByte, int start, int length) get String byte[] strByte = Arrays.copyOfRange(originalByte, start, start + length); return new String(strByte); |
String | getString(byte[] value) get String StringBuilder stringBuilder = new StringBuilder(""); for (int i = 0; i < value.length; i++) { int v = value[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0); stringBuilder.append(hv); ... |
String | getStringByByteArray(byte[] b) get String By Byte Array return new String(b); |
String | toByteString(byte[] bytes) to Byte String StringBuilder byteString = new StringBuilder(); for (byte b : bytes) { if (b >= 32 && b <= 127) { byteString.append((char) b); } else { byteString.append(String.format("\\x%02x", b)); return byteString.toString(); |
String | toByteString(byte[] bytes, int start, int length) to Byte String StringBuilder byteString = new StringBuilder(); int maxlength = bytes.length < start + length ? bytes.length : start + length; for (int i = start; i < maxlength; i++) { if (bytes[i] >= 32 && bytes[i] <= 127) { byteString.append((char) bytes[i]); } else { byteString.append(String.format("\\x%02x", bytes[i])); ... |