Browse Source

add tohexArray

tags/2.0.1
Jonathan Cobb 5 years ago
parent
commit
0c2099a105
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      src/main/java/org/cobbzilla/util/string/StringUtil.java

+ 13
- 0
src/main/java/org/cobbzilla/util/string/StringUtil.java View File

@@ -284,6 +284,19 @@ public class StringUtil {
return b.toString(); return b.toString();
} }


public static String tohexArray(byte[] data) {
return tohexArray(data, 0, data.length, ", ");
}
public static String tohexArray(byte[] data, int start, int len, String delim) {
StringBuilder b = new StringBuilder();
int stop = start+len;
for (int i=start; i<stop; i++) {
if (b.length() > 0) b.append(delim);
b.append("0x").append(getHexValue(data[i]));
}
return b.toString();
}

/** /**
* Get the hexadecimal string representation for a byte. * Get the hexadecimal string representation for a byte.
* The leading 0x is not included. * The leading 0x is not included.


Loading…
Cancel
Save