List of utility methods to do Hex Format
String | formatHexToString(byte[] bytes) format Hex To String StringBuffer buffer = new StringBuffer(); buffer.append("["); for (byte b : bytes) { buffer.append(String.format("0x%02X,", b)); buffer.append("]"); return buffer.toString(); |
String | formatInHex(byte[] bySrc, int nLineLen) format In Hex final String sRepalce = "\n\t\r\0"; int nLength = bySrc.length; int nLine = nLength / nLineLen + 1; String sLineTmp = ""; byte[] byNew = new byte[nLine * nLineLen]; for (int i = 0; i < nLength; i++) byNew[i] = bySrc[i]; String sRet = ""; ... |
String | formatText(String value, boolean showAsHexFlag) reads an String representation of an Integer, if the showAsHexFlag is set, it converts it to hex to a hex string representation for display try { int numberToCheck = Integer.parseInt(value); if (showAsHexFlag) { StringBuffer buffer = new StringBuffer(); buffer.append("0x"); buffer.append(Integer.toHexString(numberToCheck)); value = buffer.toString(); } catch (NumberFormatException nfe) { return value; |
StringBuilder | formatToHex(int rgb) format To Hex StringBuilder toReturn = new StringBuilder(Integer.toHexString(rgb & 0xffffff)); while (toReturn.length() < 6) { toReturn.insert(0, 0); return toReturn; |