类 Bytes

java.lang.Object
com.weicoder.common.lang.Bytes
直接已知子类:
W.B

public sealed class Bytes extends Object permits W.B
字节数组操作
作者:
WD
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static byte[]
    add(byte[]... bs)
    字节数组相连
    static byte[]
    binary(Object binary)
    转换Binary序列化
    static byte[]
    copy(byte[] b)
    拷贝字节数组
    static byte[]
    copy(byte[] b, int len)
    拷贝字节数组
    static byte[]
    copy(byte[] b, int offset, int len)
    拷贝字节数组
    static boolean
    isType(Class<?> c)
    是否支持序列化类型
    static Object
    to(byte[] b, Class<?> c)
    根据c类型反序列化
    static ByteArray
    toBean(ByteArray array, byte[] b)
    把字节数组转换为ByteArray
    static ByteArray
    toBean(ByteArray array, byte[] b, int offset)
    把字节数组转换为ByteArray
    static ByteArray
    toBean(ByteArray array, byte[] b, int offset, int len)
    把字节数组转换为ByteArray
    static <B> B
    toBinary(byte[] b, Class<B> c)
    读取字节数组变成对象
    static boolean
    toBoolean(byte[] b)
    把字节数组转换成int
    static boolean
    toBoolean(byte[] b, int offset)
    把字节数组转换成int
    static byte
    toByte(byte[] b)
    把字节数组转换成int
    static byte
    toByte(byte[] b, int offset)
    把字节数组转换成int
    static byte[]
    toBytes(boolean b)
    转换Collection变成字节数组
    static byte[]
    toBytes(boolean is, Object obj)
    转换Object变成字节数组
    static byte[]
    toBytes(char c)
    转换char变成字节数组
    static byte[]
    toBytes(double d)
    转换double变成字节数组
    static byte[]
    toBytes(float f)
    转换float变成字节数组
    static byte[]
    toBytes(int i)
    转换int变成字节数组
    static byte[]
    toBytes(long l)
    转换long变成字节数组
    static byte[]
    toBytes(short s)
    转换short变成字节数组
    static byte[]
    toBytes(Binary binary)
    转换Binary序列化
    static byte[]
    转换ByteArray变成字节数组
    static byte[]
    toBytes(Boolean is, Object... objs)
    转换Object变成字节数组
    static byte[]
    转换Object变成字节数组
    static byte[]
    toBytes(Object... objs)
    转换Object变成字节数组
    static byte[]
    转换String变成字节数组
    static byte[]
    toBytes(String s, boolean is)
    转换String变成字节数组
    static byte[]
    转换ByteBuffer变成字节数组
    static byte[]
    toBytes(List<?> list)
    对List列表内内容可以进行序列化 注不加头直接按列表顺序序列化
    static char
    toChar(byte[] b)
    把字节数组转换成char
    static char
    toChar(byte[] b, int offset)
    把字节数组转换成char
    static double
    toDouble(byte[] b)
    把字节数组转换成double
    static double
    toDouble(byte[] b, int offset)
    把字节数组转换成double
    static float
    toFloat(byte[] b)
    把字节数组转换成float
    static float
    toFloat(byte[] b, int offset)
    把字节数组转换成float
    static int
    toInt(byte[] b)
    把字节数组转换成int
    static int
    toInt(byte[] b, int offset)
    把字节数组转换成int
    static long
    toLong(byte[] b)
    把字节数组转换成long
    static long
    toLong(byte[] b, boolean high)
    把字节数组转换成long
    static long
    toLong(byte[] b, int offset)
    把字节数组转换成long
    static long
    toLong(byte[] b, int offset, boolean high)
    把字节数组转换成long
    static short
    toShort(byte[] b)
    把字节数组转换成short
    static short
    toShort(byte[] b, int offset)
    把字节数组转换成short
    static String
    toString(byte[] b)
    把字节数组转换成long
    static String
    toString(byte[] b, int offset)
    把字节数组转换成字符串
    static String
    toString(byte[] b, int offset, boolean is)
    把字节数组转换成字符串

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • Bytes

      public Bytes()
  • 方法详细资料

    • isType

      public static boolean isType(Class<?> c)
      是否支持序列化类型
      参数:
      c - 类
      返回:
      是否支持序列化
    • to

      public static Object to(byte[] b, Class<?> c)
      根据c类型反序列化
      参数:
      b - 要转换的对象
      c - 要转换的类型
      o - 偏移量 数组0就可以 定义成数组是为了引用传递
      返回:
      转换后的对象
    • toBytes

      public static byte[] toBytes(Object... objs)
      转换Object变成字节数组
      参数:
      objs - 对象
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(Boolean is, Object... objs)
      转换Object变成字节数组
      参数:
      objs - 对象
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(boolean b)
      转换Collection变成字节数组
      参数:
      b - 布尔
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(Object obj)
      转换Object变成字节数组
      参数:
      obj - 对象
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(List<?> list)
      对List列表内内容可以进行序列化 注不加头直接按列表顺序序列化
      参数:
      list - 列表
      返回:
      序列化后
    • toBytes

      public static byte[] toBytes(boolean is, Object obj)
      转换Object变成字节数组
      参数:
      obj - 对象
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(Binary binary)
      转换Binary序列化
      参数:
      binary - Binary接口
      返回:
      字节数组
    • binary

      public static byte[] binary(Object binary)
      转换Binary序列化
      参数:
      binary - Binary接口
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(ByteArray array)
      转换ByteArray变成字节数组
      参数:
      array - ByteArray类型
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(ByteBuffer buff)
      转换ByteBuffer变成字节数组
      参数:
      buff - ByteBuffer类型
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(int i)
      转换int变成字节数组
      参数:
      i - int类型
      返回:
      字节数组
    • toInt

      public static int toInt(byte[] b)
      把字节数组转换成int
      参数:
      b - 字节数组
      返回:
      int
    • toByte

      public static byte toByte(byte[] b)
      把字节数组转换成int
      参数:
      b - 字节数组
      返回:
      int
    • toByte

      public static byte toByte(byte[] b, int offset)
      把字节数组转换成int
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      int
    • toBoolean

      public static boolean toBoolean(byte[] b)
      把字节数组转换成int
      参数:
      b - 字节数组
      返回:
      int
    • toBoolean

      public static boolean toBoolean(byte[] b, int offset)
      把字节数组转换成int
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      int
    • toInt

      public static int toInt(byte[] b, int offset)
      把字节数组转换成int
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      int
    • toBytes

      public static byte[] toBytes(short s)
      转换short变成字节数组
      参数:
      s - short类型
      返回:
      字节数组
    • toShort

      public static short toShort(byte[] b)
      把字节数组转换成short
      参数:
      b - 字节数组
      返回:
      short
    • toShort

      public static short toShort(byte[] b, int offset)
      把字节数组转换成short
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      short
    • toBytes

      public static byte[] toBytes(char c)
      转换char变成字节数组
      参数:
      c - char类型
      返回:
      字节数组
    • toChar

      public static char toChar(byte[] b)
      把字节数组转换成char
      参数:
      b - 字节数组
      返回:
      char
    • toChar

      public static char toChar(byte[] b, int offset)
      把字节数组转换成char
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      char
    • toBytes

      public static byte[] toBytes(float f)
      转换float变成字节数组
      参数:
      f - float类型
      返回:
      字节数组
    • toFloat

      public static float toFloat(byte[] b)
      把字节数组转换成float
      参数:
      b - 字节数组
      返回:
      float
    • toFloat

      public static float toFloat(byte[] b, int offset)
      把字节数组转换成float
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      float
    • toBytes

      public static byte[] toBytes(double d)
      转换double变成字节数组
      参数:
      d - double类型
      返回:
      字节数组
    • toDouble

      public static double toDouble(byte[] b)
      把字节数组转换成double
      参数:
      b - 字节数组
      返回:
      double
    • toDouble

      public static double toDouble(byte[] b, int offset)
      把字节数组转换成double
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      double
    • toBytes

      public static byte[] toBytes(long l)
      转换long变成字节数组
      参数:
      l - long类型
      返回:
      字节数组
    • toLong

      public static long toLong(byte[] b)
      把字节数组转换成long
      参数:
      b - 字节数组
      返回:
      long
    • toLong

      public static long toLong(byte[] b, boolean high)
      把字节数组转换成long
      参数:
      b - 字节数组
      high - true 高位在前 false 低位在前
      返回:
      long
    • toLong

      public static long toLong(byte[] b, int offset)
      把字节数组转换成long
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      long
    • toLong

      public static long toLong(byte[] b, int offset, boolean high)
      把字节数组转换成long
      参数:
      b - 字节数组
      offset - 偏移
      high - true 高位在前 false 低位在前
      返回:
      long
    • toBytes

      public static byte[] toBytes(String s)
      转换String变成字节数组
      参数:
      s - String类型
      返回:
      字节数组
    • toBytes

      public static byte[] toBytes(String s, boolean is)
      转换String变成字节数组
      参数:
      s - String类型
      is - 是否加上长度
      返回:
      字节数组
    • toString

      public static String toString(byte[] b)
      把字节数组转换成long
      参数:
      b - 字节数组
      返回:
      long
    • toString

      public static String toString(byte[] b, int offset)
      把字节数组转换成字符串
      参数:
      b - 字节数组
      offset - 偏移
      返回:
      字符串
    • toString

      public static String toString(byte[] b, int offset, boolean is)
      把字节数组转换成字符串
      参数:
      b - 字节数组
      offset - 偏移
      is - 是否读取长度
      返回:
      字符串
    • copy

      public static byte[] copy(byte[] b)
      拷贝字节数组
      参数:
      b - 字节数组
      返回:
      字节数组
    • copy

      public static byte[] copy(byte[] b, int len)
      拷贝字节数组
      参数:
      b - 字节数组
      len - 长度
      返回:
      字节数组
    • copy

      public static byte[] copy(byte[] b, int offset, int len)
      拷贝字节数组
      参数:
      b - 字节数组
      offset - 偏移
      len - 长度
      返回:
      字节数组
    • toBean

      public static ByteArray toBean(ByteArray array, byte[] b)
      把字节数组转换为ByteArray
      参数:
      array - ByteArray 对象
      b - 字节数组
      返回:
      ByteArray对象
    • toBean

      public static ByteArray toBean(ByteArray array, byte[] b, int offset)
      把字节数组转换为ByteArray
      参数:
      array - ByteArray 对象
      b - 字节数组
      offset - 偏移
      返回:
      ByteArray对象
    • toBean

      public static ByteArray toBean(ByteArray array, byte[] b, int offset, int len)
      把字节数组转换为ByteArray
      参数:
      array - ByteArray 对象
      b - 字节数组
      offset - 偏移
      len - 长度
      返回:
      ByteArray对象
    • toBinary

      public static <B> B toBinary(byte[] b, Class<B> c)
      读取字节数组变成对象
      类型参数:
      B - 泛型
      参数:
      b - 字节数组
      c - 序列化类
      返回:
      对象
    • add

      public static byte[] add(byte[]... bs)
      字节数组相连
      参数:
      bs - 字节数组
      返回:
      相连后的数组