Java Utililty Methods Hex Format

List of utility methods to do Hex Format

  1. HOME
  2. Java
  3. H
  4. Hex Format

Description

The list of methods to do Hex Format are organized into topic(s).

Method

String formatAddress6(int[] hexRepresentation)
Converts IPV6 int[] representation into valid IPV6 string literal.
if (hexRepresentation == null) {
 throw new NullPointerException();
if (hexRepresentation.length != IPV6_LEN) {
 throw new IllegalArgumentException();
StringBuilder stringBuilder = new StringBuilder();
boolean inCompressedSection = false;
...
String FormatAs2CharHexa(byte byValue)
Format As Char Hexa
if (byValue < 0)
 return FormatAs2CharHexa((int) byValue + 256);
else
 return FormatAs2CharHexa((int) byValue);
String FormatAs4CharHexa(int nValue)
Format As Char Hexa
String cs = "";
char c;
for (int n = 0; n < 4; n++) {
 int nChar = nValue % 16;
 nValue = nValue / 16;
 if (nChar <= 9)
 c = (char) ('0' + nChar);
 else
...
String formatAsHex(byte[] bytes)
Formats the specified byte array as a hex string.
if (bytes == null || bytes.length == 0)
 return "";
char[] chars = new char[bytes.length * 2];
for (int i = 0; i < bytes.length; i++) {
 int b = bytes[i] & 0xff;
 chars[i * 2] = hexDigits[b >>> 4];
 chars[i * 2 + 1] = hexDigits[b & 0x0f];
return new String(chars);
String formatAsHex(long msgId)
format As Hex
String msgIdStr = String.format("%07x", msgId);
return msgIdStr.toLowerCase(); 
String formatAsHexUppercase(long msgId)
format As Hex Uppercase
return formatAsHex(msgId).toUpperCase();
String formatAsRawHex(int bitStringLength, String hex)
creates a epc-hex representation of a given tag.
return String.format("urn:epc:raw:%d.x%s", bitStringLength, hex);
String formatBytes2HexString(byte[] bytes, int offset, int length)
format Bytes Hex String
final int startIndex = offset;
final int fullRows = length >>> 4;
final int remainder = length & 0xF;
StringBuilder dump = new StringBuilder();
dump.append(" +-------------------------------------------------+" + NEWLINE
 + " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |" + NEWLINE
 + "+--------+-------------------------------------------------+----------------+");
for (int row = 0; row < fullRows; row++) {
...
String formatByteToPaddedHex(int i, int l)
format Byte To Padded Hex
StringBuilder hex = new StringBuilder(Integer.toString(i, 16).toUpperCase());
while (hex.length() < l) {
 hex.insert(0, "0");
return hex.toString();
String formatColorInt2HexString(int c)
format Color Int Hex String
String s = "";
try {
 s = String.format("#%06X", (0xFFFFFF & c));
} catch (Exception e) {
return s;


AltStyle によって変換されたページ (->オリジナル) /