List of utility methods to do Byte Array Convert To
String | bytesToStringMac(byte[] mac) bytes To String Mac StringBuilder sb = new StringBuilder(18); for (byte b : mac) { if (sb.length() > 0) { sb.append(':'); sb.append(String.format("%02x", b)); return sb.toString(); ... |
String | bytesToStringUTFCustom(byte[] bytes) Use during externalization methods....FAST as it avoids charset encoding From http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html char[] buffer = new char[bytes.length >> 1]; for (int i = 0; i < buffer.length; i++) { int bpos = i << 1; char c = (char) (((bytes[bpos] & 0x00FF) << 8) + (bytes[bpos + 1] & 0x00FF)); buffer[i] = c; return new String(buffer); |
long | bytesToSVar64(final byte[] buffer, final int offset) bytes To S Var return zigzagToLong(bytesToVar64(buffer, offset));
|
int | bytesToTagBE(byte[] bytes, int off) bytes To Tag BE return bytesToIntBE(bytes, off);
|
String | bytesToText(byte[] bytes) Convert bytes to text StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { int num = bytes[i]; if (num < 0) num = 127 + (num * -1); String hex = Integer.toHexString(num); if (hex.length() == 1) { hex = "0" + hex; ... |
short | BytesToUInt16(byte[] pb) Bytes To U Int assert (pb != null) && (pb.length == 2); if (pb == null) throw new IllegalArgumentException("pb"); if (pb.length != 2) throw new IllegalArgumentException(); return (short) (bint(pb[0]) | (bint(pb[1]) << 8)); |
int | bytesToVar32(final byte[] buffer, final int offset) bytes To Var if (buffer == null) { throw new NullPointerException("buffer must not be null"); checkBound(buffer.length, offset); fastpath: { int pos = offset; final int bufferSize = buffer.length; if (bufferSize == pos) { ... |