Guava Bytes 工具类
Bytes 是 byte 的基本类型实用工具类。
一、类声明
以下是com.google.common.primitives.Bytes类的声明:
@GwtCompatible public final class Bytes extends Object
二、类方法
官方文档:https://google.github.io/guava/releases/27.0.1-jre/api/docs/com/google/common/primitives/Bytes.html
| 修饰符和类型 | 方法说明 | 
|---|---|
| static List<Byte> | asList(byte... backingArray)基本类型数组转化为包装类List. | 
| static byte[] | concat(byte[]... arrays)将多个byte数组拼接成一个数组. | 
| static boolean | contains(byte[] array, byte target)判断一个byte数是否在byte数组内. | 
| static byte[] | ensureCapacity(byte[] array, int minLength, int padding)确保数组拥有一个最小的长度,如果array长度小于minLength,则会返回一个元素值与array相同,但是length = minLength + padding的数组. | 
| static int | hashCode(byte value)返回int值的hashCode(hashCode等于元素值). | 
| static int | indexOf(byte[] array, byte target)返回一个byte值在数组中的第一个index,没匹配到返回-1. | 
| static int | indexOf(byte[] array, byte[] target)返回byte数组在另一个数组中的第一个index,没匹配到返回-1. | 
| static int | lastIndexOf(byte[] array, byte target)返回一个byte值在数组中的最后一个index,没匹配到返回-1. | 
| static void | reverse(byte[] array)将数组反转. | 
| static void | reverse(byte[] array, int fromIndex, int toIndex)将数组指定范围的元素反转(范围左闭右开). | 
| static byte[] | toArray(Collection<? extends Number> collection)List转数组. | 
三、测试类
测试方法与 Ints 中的方法类似,不过多说明,详见 Ints 文章
四、相关文章
未经允许请勿转载:程序喵 » Google Guava 快速入门 —— 【原生类型工具】Bytes 类
 程序喵
程序喵