Module jcifs

Class Hexdump

java.lang.Object
org.codelibs.jcifs.smb.util.Hexdump

public class Hexdump extends Object
Utility class for hexadecimal dumping of binary data. This class provides methods for converting binary data to readable hex format.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char[]
    Array of hexadecimal digit characters used for converting binary data to hex representation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    toHexChars(int val, char[] dst, int dstIndex, int size)
    This is the same as toHexString(int val, int size) but provides a more practical form when trying to avoid String concatenation and StringBuffer.
    static void
    toHexChars(long val, char[] dst, int dstIndex, int size)
    Converts a long value to hexadecimal characters and writes them to the specified character array.
    static String
    toHexString(byte[] data)
    Converts a byte array to a hexadecimal string representation.
    static String
    toHexString(byte[] src, int srcIndex, int size)
    Converts a byte array to a hexadecimal string representation.
    static String
    toHexString(int val, int size)
    This is an alternative to the java.lang.Integer.toHexString method.
    static String
    toHexString(long val, int size)
    Converts a long value to a hexadecimal string representation with specified padding.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HEX_DIGITS

      public static final char[] HEX_DIGITS
      Array of hexadecimal digit characters used for converting binary data to hex representation.
  • Constructor Details

    • Hexdump

      public Hexdump()
      Default constructor.
  • Method Details

    • toHexString

      public static String toHexString(int val, int size)
      This is an alternative to the java.lang.Integer.toHexString method. It is an efficient relative that also will pad the left side so that the result is size digits.
      Parameters:
      val - the integer value to convert to hexadecimal
      size - the desired length of the resulting hex string (will be left-padded with zeros)
      Returns:
      a hexadecimal string representation of the value, padded to the specified size
    • toHexString

      public static String toHexString(long val, int size)
      Converts a long value to a hexadecimal string representation with specified padding.
      Parameters:
      val - the long value to convert to hexadecimal
      size - the desired length of the resulting hex string (will be left-padded with zeros)
      Returns:
      a hexadecimal string representation of the value, padded to the specified size
    • toHexString

      public static String toHexString(byte[] src, int srcIndex, int size)
      Converts a byte array to a hexadecimal string representation.
      Parameters:
      src - the source byte array to convert
      srcIndex - the starting index in the source array
      size - the number of bytes to convert from the source array
      Returns:
      a hexadecimal string representation of the byte array
    • toHexString

      public static String toHexString(byte[] data)
      Converts a byte array to a hexadecimal string representation.
      Parameters:
      data - the byte array to convert
      Returns:
      a hexadecimal string representation of the entire byte array
    • toHexChars

      public static void toHexChars(int val, char[] dst, int dstIndex, int size)
      This is the same as toHexString(int val, int size) but provides a more practical form when trying to avoid String concatenation and StringBuffer.
      Parameters:
      val - the integer value to convert to hexadecimal characters
      dst - the destination character array to write the hex digits into
      dstIndex - the starting index in the destination array
      size - the number of hex digits to write (will be left-padded with zeros)
    • toHexChars

      public static void toHexChars(long val, char[] dst, int dstIndex, int size)
      Converts a long value to hexadecimal characters and writes them to the specified character array.
      Parameters:
      val - the long value to convert to hexadecimal characters
      dst - the destination character array to write the hex digits into
      dstIndex - the starting index in the destination array
      size - the number of hex digits to write (will be left-padded with zeros)