Package com.adaptris.util.text
Class Conversion
java.lang.Object
com.adaptris.util.text.Conversion
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 Summary
Modifier and TypeMethodDescriptionstatic byte[]
Deprecated.static String
byteArrayToBase64String
(byte[] b) Deprecated.since 3.10, useBase64
instead.static String
byteArrayToHexString
(byte[] b) Convert a byte array to a hexadecimal String.static String
byteToHexString
(byte b) Convert a byte to a hexadecimal String.static byte[]
Parses the supplied String into a byte[] - assumes that the text is in hex format.
-
Method Details
-
byteToHexString
Convert a byte to a hexadecimal String.- Parameters:
b
- a single byte- Returns:
- the hex String
-
byteArrayToHexString
Convert a byte array to a hexadecimal String.- Parameters:
b
- the bytes- Returns:
- the hex String
-
byteArrayToBase64String
Deprecated.since 3.10, useBase64
instead.Convert a byte array to a base 64 string (see RFC 1421).- Parameters:
b
- the bytes- Returns:
- the String
-
base64StringToByteArray
Deprecated.since 3.10, useBase64
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
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
-
Base64
instead.