Bytes is a utility class for primitive type byte. It provides
Static utility methods pertaining to byte primitives, that are not already found in either Byte or Arrays and interpret bytes as neither signed nor unsigned. The methods which specifically treat bytes as signed or unsigned are found in
SignedBytes and
UnsignedBytes.
Declaration :
@GwtCompatible(emulated=true)
public final class Bytes
extends Object
Below table shows the methods provided by Guava Bytes Class :
👁 Image
Exceptions :
- ensureCapacity : IllegalArgumentException if minLength or padding is negative.
- toArray : NullPointerException if collection or any of its elements is null.
Below given are some examples showing the implementation of Guava Bytes Class methods :
Example 1 :
Output :
[3, 4, 5, 6, 7]
Example 2 :
Output :
2
Example 3 :
Output :
[3, 4, 5, 6, 7]
Example 4 :
output :
false
true
Example 5 :
Output :
6
Example 6 :