List of utility methods to do Byte Array to String
String | bytes2Str(byte[] bytes, String separator) Converts byte array to string StringBuilder stringBuilder = new StringBuilder(); for (int index = 0; index < bytes.length; index++) { stringBuilder.append(index == 0 ? "" : separator).append(((int) bytes[index]) & 0xFF); return stringBuilder.toString(); |
String | bytes2String(byte[] args) bytes String String str = new String(args); return str; |
String | bytes2String(byte[] b, int start, int len) bytes String return new String(b, start, len); |
String | bytes2String(byte[] bs, String charset) bytes String if (null == bs) { return EMPTY_STRING; String s = null; try { s = new String(bs, charset); } catch (Exception e) { return s; |
String | bytes2String(byte[] buffer, int offset, int length) bytes String StringBuilder sb = new StringBuilder(); for (int i = offset; i < offset + length; i++) { byte b = buffer[i]; sb.append(String.format("%02X", b)); sb.append(" "); return sb.toString(); |
String | bytes2String(byte[] bytes) bytes String if (bytes == null || bytes.length == 0) return ""; StringBuffer sb = new StringBuffer(); for (byte b : bytes) sb.append(byte2HEX(b)); return sb.toString(); |
String | bytes2String(byte[] bytes) bytes String StringBuilder string = new StringBuilder(); for (byte b : bytes) { String hexString = Integer.toHexString(0x00FF & b); string.append(hexString.length() == 1 ? "0" + hexString : hexString); return string.toString(); |
String | bytes2String(byte[] bytes) bytes String StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { stringBuffer.append((char) bytes[i]); return stringBuffer.toString(); |
String | bytes2String(byte[] bytesArray) bytes String String result = ""; for (Byte bts : bytesArray) { result += (char) bts.intValue(); return result; |
String | bytes2String(byte[] data) bytes String if (data == null) return null; if (data.length == 0) return ""; StringBuilder sb = new StringBuilder(); for (byte b : data) { sb.append(b).append(' '); return sb.toString(); |