java.lang.Object
org.firebirdsql.jaybird.util.ByteArrayHelper
Helper methods for byte arrays.
- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
static byte[]
fromBase64String
(String base64) Decodes a base64 encoded string to a byte array.static byte[]
fromBase64urlString
(String base64url) Decodes a base64url encoded string to a byte array.static byte[]
fromHexString
(String hexString) Converts the provided hexadecimal string to a byte array.static int
indexOf
(byte[] array, byte b) Returns the index of the first occurrence ofb
inarray
.static String
toHexString
(byte[] bytes) Converts the provided byte array to a hexadecimal string.
-
Method Details
-
toHexString
Converts the provided byte array to a hexadecimal string.- Parameters:
bytes
- byte array (notnull
- Returns:
- String with the content of the byte array in hexadecimal.
-
fromHexString
Converts the provided hexadecimal string to a byte array.- Parameters:
hexString
- Hexadecimal string- Returns:
- byte array
- Since:
- 4.0
-
fromBase64String
Decodes a base64 encoded string to a byte array.- Parameters:
base64
- Base64 encoded data- Returns:
- byte array after decoding
-
fromBase64urlString
Decodes a base64url encoded string to a byte array.Base64url applies the "URL and Filename safe" Base 64 Alphabet.
- Parameters:
base64url
- Base64url encoded data- Returns:
- byte array after decoding
- Since:
- 5
-
indexOf
public static int indexOf(byte[] array, byte b) Returns the index of the first occurrence ofb
inarray
.- Parameters:
array
- Array to searchb
- byte to find- Returns:
- the index of the first occurrence of
b
, or-1
ifb
is not in the array - Since:
- 5
-
emptyByteArray
public static byte[] emptyByteArray()- Returns:
- an empty array (length == 0)
-