List of utility methods to do Byte Array Create
String | toByteString(byte[] bytes, String seperator) to Byte String StringBuffer buffer = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if (i > 0 && seperator != null) buffer.append(seperator); buffer.append(toByteString(bytes[i])); return buffer.toString(); |
String | toByteString(byte[] content, int len) to Byte String if (content == null || content.length == 0) { return ""; if (len > content.length) { len = content.length; StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { ... |
String | toByteString(final byte[] b) to Byte String return new String(asChars(b)); |
String | toByteString(final String source) to Byte String if (source == null) { return null; if (source.length() == 0) { return ""; final char[] chars = source.toCharArray(); final byte[] bytes = new byte[source.length() * 2]; ... |
int | toBytesWithLength(byte[] buffer, int pos, String string) to Bytes With Length byte[] strBytes = string.getBytes(); if (strBytes.length > 32767) { throw new RuntimeException("Payload is too long; " + strBytes.length); buffer[pos] = (byte) (strBytes.length / 256); buffer[pos + 1] = (byte) (strBytes.length & 255); System.arraycopy(strBytes, 0, buffer, pos + 2, strBytes.length); return pos + strBytes.length + 2; ... |
int | toBytesWithLengthLong(byte[] buffer, int pos, byte[] bytes) to Bytes With Length Long buffer[pos] = (byte) (bytes.length >> 24); buffer[pos + 1] = (byte) ((bytes.length >> 16) & 255); buffer[pos + 2] = (byte) ((bytes.length >> 8) & 255); buffer[pos + 3] = (byte) (bytes.length & 255); System.arraycopy(bytes, 0, buffer, pos + 4, bytes.length); return pos + bytes.length + 4; |