Package org.eclipse.net4j.util

# Class HexUtil

java.lang.Object
org.eclipse.net4j.util.HexUtil

public final class HexUtil extends Object
Provides static methods that convert to and from hexadecimal string formats.

Author:
  Eike Stepper

## Field Summary

Fields
Modifier and Type
Field
Description
`static final char[]`
`DIGITS`

## Method Summary

Modifier and Type
Method
Description
`static void`
`appendHex(StringBuilder builder, int b)`
Deprecated.
`static String`
`bytesToHex(byte[] bs)`
`static String`
`bytesToHex(byte[] bs, int off, int length)`
Converts a byte array into a string of lower case hex chars.
`static void`
`bytesToHex(InputStream bs, Writer writer)`
`static void`
`bytesToHexAppend(byte[] bs, int off, int length, Appendable appendable)`
`static String`
`charToHex(char ch)`
`static String`
`formatByte(int b)`
Deprecated.
`static String`
`formatBytes(byte[] bytes)`
Deprecated.
`static void`
`hexToBytes(Reader s, OutputStream outputStream)`
`static byte[]`
`hexToBytes(String s)`
`static void`
`hexToBytes(String s, byte[] out, int off)`
Converts a String of hex characters into an array of bytes.
`static byte[]`
`hexToBytes(String s, int off)`
`static char`
`hexToChar(String s)`
`static String`
`identityHashCode(Object object)`
`static String`
`identityHashCode(Object object, boolean trimLeadingZeros)`
`static String`
`intToHex(int v)`
`static String`
`longToHex(long v)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DIGITS

public static final char[] DIGITS

## Method Details

### charToHex

public static String charToHex(char ch)

Since:
  3.22

### hexToChar

public static char hexToChar(String s)

Since:
  3.22

### bytesToHex

public static String bytesToHex(byte[] bs, int off, int length)
Converts a byte array into a string of lower case hex chars.

Parameters:
  `bs` - A byte array
  `off` - The index of the first byte to read
  `length` - The number of bytes to read.
Returns:
  the string of hex chars.

### bytesToHexAppend

public static void bytesToHexAppend(byte[] bs, int off, int length, Appendable appendable)

### bytesToHex

public static void bytesToHex(InputStream bs, Writer writer)

Since:
  3.7

### bytesToHex

public static String bytesToHex(byte[] bs)

### hexToBytes

public static byte[] hexToBytes(String s)

### hexToBytes

public static byte[] hexToBytes(String s, int off)

### hexToBytes

public static void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, IndexOutOfBoundsException
Converts a String of hex characters into an array of bytes.

Parameters:
  `s` - A string of hex characters (upper case or lower) of even length.
  `out` - A byte array of length at least s.length()/2 + off
  `off` - The first byte to write of the array
Throws:
  `NumberFormatException`
  `IndexOutOfBoundsException`

### hexToBytes

public static void hexToBytes(Reader s, OutputStream outputStream) throws NumberFormatException

Throws:
  `NumberFormatException`
Since:
  3.7

### longToHex

public static String longToHex(long v)

### intToHex

public static String intToHex(int v)

Since:
  3.13

### identityHashCode

public static String identityHashCode(Object object)

Since:
  3.13

### identityHashCode

public static String identityHashCode(Object object, boolean trimLeadingZeros)

Since:
  3.20

### formatByte

@Deprecated public static String formatByte(int b)
Deprecated.

### formatBytes

@Deprecated public static String formatBytes(byte[] bytes)
Deprecated.

### appendHex

@Deprecated public static void appendHex(StringBuilder builder, int b)
Deprecated.