public class BinaryUtils extends Object
Constructor and Description |
---|
BinaryUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
copyAllBytesFrom(ByteBuffer bb) |
static byte[] |
fromBase64(String b64Data)
Converts a Base64-encoded string to the original byte data.
|
static byte[] |
fromHex(String hexData)
Converts a Hex-encoded data string to the original byte data.
|
static String |
toBase64(byte[] data)
Converts byte data to a Base64-encoded string.
|
static String |
toHex(byte[] data)
Converts byte data to a Hex-encoded string.
|
static InputStream |
toStream(ByteBuffer byteBuffer)
Wraps a ByteBuffer in an InputStream.
|
public static String toHex(byte[] data)
data
- data to hex encode.public static byte[] fromHex(String hexData)
hexData
- hex-encoded data to decode.public static String toBase64(byte[] data)
data
- data to Base64 encode.public static byte[] fromBase64(String b64Data)
b64Data
- a Base64-encoded string to decode.public static InputStream toStream(ByteBuffer byteBuffer)
byteBuffer
- The ByteBuffer to wrap.public static byte[] copyAllBytesFrom(ByteBuffer bb)
bb
- the byte buffer.ByteBuffer
,
from the beginning to the buffer's limit; or null if the input is null.
The internal states of the given byte buffer will be restored when this method completes execution.
When handling ByteBuffer
from user's input, it's typical to
call the #copyBytesFrom(ByteBuffer)
instead of
copyAllBytesFrom(ByteBuffer)
so as to account for the position
of the input ByteBuffer
. The opposite is typically true,
however, when handling ByteBuffer
from within the
unmarshallers of the low-level clients.
Copyright © 2017. All rights reserved.