Package org.dellroad.stuff.string
Class ByteArrayEncoder
java.lang.Object
org.dellroad.stuff.string.ByteArrayEncoder
Encodes
byte[] arrays to and from hexadecimal strings.-
Method Summary
-
Method Details
-
encode
- Parameters:
array- byte array, ornull- Returns:
- hexadecimal string (or
nullifarraywasnull)
-
encode
Encode abyte[]array as aString.- Parameters:
array- byte array, ornulloff- offset into the arraylen- number of bytes to convert- Returns:
- hexadecimal string (or
nullifarraywasnull) - Throws:
IndexOutOfBoundsException- if array bounds are exceededIllegalArgumentException- iflenis greater thanInteger.MAX_VALUE / 2
-
decode
Decode aStringback into abyte[]array. Any extra whitespace in the string is ignored.- Parameters:
text- string previously encoded byencode(byte[]), ornull- Returns:
- original
byte[]array (ornulliftextwasnull) - Throws:
IllegalArgumentException- if any invalid non-whitespace characters are seen, or the number of hex digits is odd
-