Class Conversion

java.lang.Object
com.adaptris.util.text.Conversion

public final class Conversion extends Object
Simple Data Conversion methods.

Only small amounts of data should be converted using this class, to write a large number of bytes as a Base64 String, an alternative method such as IAIK's Base64OutputStream should be used, or javax.mail.internet.MimeUtility.

  • Method Details

    • byteToHexString

      public static String byteToHexString(byte b)
      Convert a byte to a hexadecimal String.
      Parameters:
      b - a single byte
      Returns:
      the hex String
    • byteArrayToHexString

      public static String byteArrayToHexString(byte[] b)
      Convert a byte array to a hexadecimal String.
      Parameters:
      b - the bytes
      Returns:
      the hex String
    • byteArrayToBase64String

      @Deprecated public static String byteArrayToBase64String(byte[] b)
      Deprecated.
      since 3.10, use Base64 instead.
      Convert a byte array to a base 64 string (see RFC 1421).
      Parameters:
      b - the bytes
      Returns:
      the String
    • base64StringToByteArray

      @Deprecated public static byte[] base64StringToByteArray(String s)
      Deprecated.
      since 3.10, use Base64 instead.
      Convert a base 64 string to a byte array (see RFC 1421).
      Parameters:
      s - the string
      Returns:
      the byte array
      Throws:
      NumberFormatException - if the stirng is invalid base64
    • hexStringToByteArray

      public static byte[] hexStringToByteArray(String s) throws IOException
      Parses the supplied String into a byte[] - assumes that the text is in hex format.
      Parameters:
      s - the hex String
      Returns:
      the byte array.
      Throws:
      IOException