Package org.red5.io.utils
Class HexDump
- java.lang.Object
-
- org.red5.io.utils.HexDump
-
public class HexDump extends Object
Hexadecimal byte dumper- Author:
- Niko Schweitzer
-
-
Constructor Summary
Constructors Constructor Description HexDump()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbyteArrayToBinaryString(byte[] block)Description of the Methodstatic StringbyteArrayToHexString(byte[] block)Description of the Methodstatic StringbyteArrayToHexString(byte[] block, int offset, int length)Description of the Methodstatic voiddumpHex(StringBuilder sb, byte[] b)Dumps a byte array as hex.static StringformatHexDump(String in)static byte[]hexStringToByteArray(String strA)Converts readable hex-String to byteArraystatic StringprettyPrintHex(byte[] baToConvert)Method prettyPrintHexstatic StringprettyPrintHex(String sToConvert)Method prettyPrintHexstatic StringprettyPrintHex(ByteBuffer bbToConvert)Method prettyPrintHexstatic voidsetBitDigits(char[] bd)Sets the BitDigits attribute of the Convert classstatic voidsetBitDigits(char zeroBit, char oneBit)Method setBitDigitsstatic voidsetByteSeparator(char bs)Sets the ByteSeparator attribute of the Convert classstatic voidsetWithByteSeparator(boolean bs)Sets the WithByteSeparator attribute of the Convert classstatic StringstringToHexString(String in)Description of the Methodstatic StringtoBinaryString(byte b)Method toBinaryStringstatic StringtoBinaryString(byte[] ba)Method toBinaryStringstatic StringtoBinaryString(int i)Method toBinaryStringstatic StringtoBinaryString(long l)Method toBinaryStringstatic StringtoBinaryString(short s)Method toBinaryStringstatic byte[]toByteArray(int i)Method toByteArraystatic byte[]toByteArray(long l)Method toByteArraystatic byte[]toByteArray(short s)Method toByteArraystatic StringtoHexString(byte b)Method toHexStringstatic StringtoHexString(byte[] ba)Returns a string of hexadecimal digits from a byte array.static StringtoHexString(byte[] ba, int offset, int length)converts String to Hex String.static StringtoHexString(int i)Method toHexStringstatic StringtoHexString(long l)Method toHexStringstatic StringtoHexString(short s)Description of the Methodstatic StringtoString(byte b)Method toStringstatic StringtoString(byte[] ba)Method toString
-
-
-
Method Detail
-
prettyPrintHex
public static String prettyPrintHex(ByteBuffer bbToConvert)
Method prettyPrintHex- Parameters:
bbToConvert- ByteBuffer to encode- Returns:
- Hexdump string
-
prettyPrintHex
public static String prettyPrintHex(byte[] baToConvert)
Method prettyPrintHex- Parameters:
baToConvert- Array of bytes to encode- Returns:
- Hexdump string
-
prettyPrintHex
public static String prettyPrintHex(String sToConvert)
Method prettyPrintHex- Parameters:
sToConvert- string to convert- Returns:
- hexdump string
-
dumpHex
public static void dumpHex(StringBuilder sb, byte[] b)
Dumps a byte array as hex.- Parameters:
sb- string builderb- bytes
-
setWithByteSeparator
public static void setWithByteSeparator(boolean bs)
Sets the WithByteSeparator attribute of the Convert class- Parameters:
bs- The new WithByteSeparator value
-
setByteSeparator
public static void setByteSeparator(char bs)
Sets the ByteSeparator attribute of the Convert class- Parameters:
bs- The new ByteSeparator value
-
setBitDigits
public static void setBitDigits(char[] bd) throws ExceptionSets the BitDigits attribute of the Convert class- Parameters:
bd- The new BitDigits value- Throws:
Exception- Description of Exception
-
setBitDigits
public static void setBitDigits(char zeroBit, char oneBit)Method setBitDigits- Parameters:
zeroBit- zero bitoneBit- one bit param redFish red fish param blueFish blue fish
-
byteArrayToBinaryString
public static String byteArrayToBinaryString(byte[] block)
Description of the Method- Parameters:
block- Description of Parameter- Returns:
- Description of the Returned Value
-
toBinaryString
public static String toBinaryString(byte[] ba)
Method toBinaryString- Parameters:
ba- binary array- Returns:
- the binary representation of the byte array
-
toBinaryString
public static String toBinaryString(byte b)
Method toBinaryString- Parameters:
b- byte array- Returns:
- the binary representation of the byte
-
toBinaryString
public static String toBinaryString(short s)
Method toBinaryString- Parameters:
s- short- Returns:
- the binary representation of the short
-
toBinaryString
public static String toBinaryString(int i)
Method toBinaryString- Parameters:
i- integer- Returns:
- the binary representation of the int
-
toBinaryString
public static String toBinaryString(long l)
Method toBinaryString- Parameters:
l- long- Returns:
- the binary representation of the long
-
toByteArray
public static final byte[] toByteArray(short s)
Method toByteArray- Parameters:
s- short- Returns:
- the short as array of bytes
-
toByteArray
public static final byte[] toByteArray(int i)
Method toByteArray- Parameters:
i- int- Returns:
- the int as array of bytes
-
toByteArray
public static final byte[] toByteArray(long l)
Method toByteArray- Parameters:
l- long- Returns:
- the long as array of bytes
-
byteArrayToHexString
public static String byteArrayToHexString(byte[] block)
Description of the Method- Parameters:
block- Description of Parameter- Returns:
- Description of the Returned Value
-
stringToHexString
public static String stringToHexString(String in)
Description of the Method- Parameters:
in- string to be converted- Returns:
- String in readable hex encoding
-
byteArrayToHexString
public static String byteArrayToHexString(byte[] block, int offset, int length)
Description of the Method- Parameters:
block- Description of Parameteroffset- Description of Parameterlength- Description of Parameter- Returns:
- Description of the Returned Value
-
toHexString
public static String toHexString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. Each byte is converted to 2 hex symbols.- Parameters:
ba- Description of Parameter- Returns:
- Description of the Returned Value
-
toHexString
public static String toHexString(byte b)
Method toHexString- Parameters:
b- byte- Returns:
- the hexadecimal representation of the byte
-
toHexString
public static String toHexString(short s)
Description of the Method- Parameters:
s- short- Returns:
- Description of the Returned Value
-
toHexString
public static String toHexString(int i)
Method toHexString- Parameters:
i- int- Returns:
- the hexadecimal representation of the int
-
toHexString
public static String toHexString(long l)
Method toHexString- Parameters:
l- long- Returns:
- the hexadecimal representation of the long
-
toString
public static String toString(byte[] ba)
Method toString- Parameters:
ba- byte array- Returns:
- the byte array as string
-
toString
public static String toString(byte b)
Method toString- Parameters:
b- byte- Returns:
- the byte as string
-
toHexString
public static String toHexString(byte[] ba, int offset, int length)
converts String to Hex String. Example: niko == 6E696B6F- Parameters:
ba- byte arrayoffset- offset in arraylength- number of bytes- Returns:
- Description of the Returned Value
-
hexStringToByteArray
public static byte[] hexStringToByteArray(String strA)
Converts readable hex-String to byteArray- Parameters:
strA- string- Returns:
- the hexadecimal string as byte array
-
-