List of utility methods to do Hex Calculate
String | toHex(String txt) to Hex return toHex(txt.getBytes());
|
String | toHex(String val) to Hex String ret = "0x"; for (int i = 0; i < val.length(); i++) { ret += toHex(val.charAt(i), 2); return ret; |
void | toHex(StringBuffer buf, long value, int width) to Hex if (value > (long) 1 << width * 4) { buf.append(Long.toHexString(value).toUpperCase()); return; for (int cntr = width - 1; cntr >= 0; cntr--) buf.append(HEX_CHARS[(int) (value >> (cntr * 4)) & 0xf]); |
void | toHex(StringBuilder s, byte b) to Hex char hi = Character.forDigit((b >> 4) & 0x0F, 16); char lo = Character.forDigit(b & 0x0F, 16); s.append(Character.toUpperCase(hi)); s.append(Character.toUpperCase(lo)); |
String | toHex00String(int c) to Hex String String s = Integer.toHexString(c); if (s.length() == 1) { return "0" + s; } else { return s; |
String | toHEX1(byte b) utility method to convert a byte to a hexadecimal string. char[] buf = new char[2]; int j = 0; buf[j++] = HEX_DIGITS[(b >>> 4) & 0x0F]; buf[j++] = HEX_DIGITS[b & 0x0F]; return new String(buf); |
String | toHex16(int w) to Hex return toHex((byte) (0xff & (w >> 8))) + toHex((byte) (0xff & w)); |
String | toHex16(long l) to Hex String s = "000000000000000" + Long.toHexString(l); s = s.substring(s.length() - 16); return hexUpperCase ? s.toUpperCase() : s; |
String | toHex4(int value) to Hex if (value < 0) value &= 0xffff; return padAddress(Integer.toHexString(value & 0x7fffffff).toUpperCase()); |
String | toHex8(long x) to Hex String s = Long.toHexString(x); if (s.length() % 8 != 0) { int r = 8 - s.length(); for (int i = 0; i < r; i++) s = "0" + s; return s; |