Explorar el Código

add tohexArray

tags/2.0.1
Jonathan Cobb hace 5 años
padre
commit
0c2099a105
Se han modificado 1 ficheros con 13 adiciones y 0 borrados
  1. +13
    -0
      src/main/java/org/cobbzilla/util/string/StringUtil.java

+ 13
- 0
src/main/java/org/cobbzilla/util/string/StringUtil.java Ver fichero

@@ -284,6 +284,19 @@ public class StringUtil {
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.
* The leading 0x is not included.


Cargando…
Cancelar
Guardar