Package com.weicoder.common.lang
Class Bytes
- java.lang.Object
-
- com.weicoder.common.lang.Bytes
-
- Direct Known Subclasses:
W.B
public class Bytes extends java.lang.Object字节数组操作- Author:
- WD
-
-
Constructor Summary
Constructors Constructor Description Bytes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]add(byte[]... bs)字节数组相连static byte[]binary(java.lang.Object binary)转换Binary序列化static byte[]copy(byte[] b, int offset, int len)拷贝字节数组static booleanisType(java.lang.Class<?> c)是否支持序列化类型static java.lang.Objectto(byte[] b, java.lang.Class<?> c)根据c类型反序列化static ByteArraytoBean(ByteArray array, byte[] b)把字节数组转换为ByteArraystatic ByteArraytoBean(ByteArray array, byte[] b, int offset)把字节数组转换为ByteArraystatic ByteArraytoBean(ByteArray array, byte[] b, int offset, int len)把字节数组转换为ByteArraystatic <B> BtoBinary(byte[] b, java.lang.Class<B> c)读取字节数组变成对象static booleantoBoolean(byte[] b)把字节数组转换成intstatic booleantoBoolean(byte[] b, int offset)把字节数组转换成intstatic bytetoByte(byte[] b)把字节数组转换成intstatic bytetoByte(byte[] b, int offset)把字节数组转换成intstatic byte[]toBytes(boolean b)转换Collection变成字节数组static byte[]toBytes(boolean is, java.lang.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[]toBytes(ByteArray array)转换ByteArray变成字节数组static byte[]toBytes(java.lang.Boolean is, java.lang.Object... objs)转换Object变成字节数组static byte[]toBytes(java.lang.Object obj)转换Object变成字节数组static byte[]toBytes(java.lang.Object... objs)转换Object变成字节数组static byte[]toBytes(java.lang.String s)转换String变成字节数组static byte[]toBytes(java.lang.String s, boolean is)转换String变成字节数组static byte[]toBytes(java.nio.ByteBuffer buff)转换ByteBuffer变成字节数组static chartoChar(byte[] b)把字节数组转换成charstatic chartoChar(byte[] b, int offset)把字节数组转换成charstatic doubletoDouble(byte[] b)把字节数组转换成doublestatic doubletoDouble(byte[] b, int offset)把字节数组转换成doublestatic floattoFloat(byte[] b)把字节数组转换成floatstatic floattoFloat(byte[] b, int offset)把字节数组转换成floatstatic inttoInt(byte[] b)把字节数组转换成intstatic inttoInt(byte[] b, int offset)把字节数组转换成intstatic longtoLong(byte[] b)把字节数组转换成longstatic longtoLong(byte[] b, boolean high)把字节数组转换成longstatic longtoLong(byte[] b, int offset)把字节数组转换成longstatic longtoLong(byte[] b, int offset, boolean high)把字节数组转换成longstatic shorttoShort(byte[] b)把字节数组转换成shortstatic shorttoShort(byte[] b, int offset)把字节数组转换成shortstatic java.lang.StringtoString(byte[] b)把字节数组转换成longstatic java.lang.StringtoString(byte[] b, int offset)把字节数组转换成字符串static java.lang.StringtoString(byte[] b, int offset, boolean is)把字节数组转换成字符串
-
-
-
Method Detail
-
isType
public static boolean isType(java.lang.Class<?> c)
是否支持序列化类型- Parameters:
c- 类- Returns:
- 是否支持序列化
-
to
public static java.lang.Object to(byte[] b, java.lang.Class<?> c)根据c类型反序列化- Parameters:
b- 要转换的对象o- 偏移量 数组0就可以 定义成数组是为了引用传递c- 要转换的类型- Returns:
- 转换后的对象
-
toBytes
public static byte[] toBytes(java.lang.Object... objs)
转换Object变成字节数组- Parameters:
objs- 对象- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(java.lang.Boolean is, java.lang.Object... objs)转换Object变成字节数组- Parameters:
objs- 对象- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(boolean b)
转换Collection变成字节数组- Parameters:
b- 布尔- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(java.lang.Object obj)
转换Object变成字节数组- Parameters:
obj- 对象- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(boolean is, java.lang.Object obj)转换Object变成字节数组- Parameters:
obj- 对象- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(Binary binary)
转换Binary序列化- Parameters:
binary- Binary接口- Returns:
- 字节数组
-
binary
public static byte[] binary(java.lang.Object binary)
转换Binary序列化- Parameters:
binary- Binary接口- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(ByteArray array)
转换ByteArray变成字节数组- Parameters:
array- ByteArray类型- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(java.nio.ByteBuffer buff)
转换ByteBuffer变成字节数组- Parameters:
buff- ByteBuffer类型- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(int i)
转换int变成字节数组- Parameters:
i- int类型- Returns:
- 字节数组
-
toInt
public static int toInt(byte[] b)
把字节数组转换成int- Parameters:
b- 字节数组- Returns:
- int
-
toByte
public static byte toByte(byte[] b)
把字节数组转换成int- Parameters:
b- 字节数组- Returns:
- int
-
toByte
public static byte toByte(byte[] b, int offset)把字节数组转换成int- Parameters:
b- 字节数组offset- 偏移- Returns:
- int
-
toBoolean
public static boolean toBoolean(byte[] b)
把字节数组转换成int- Parameters:
b- 字节数组- Returns:
- int
-
toBoolean
public static boolean toBoolean(byte[] b, int offset)把字节数组转换成int- Parameters:
b- 字节数组offset- 偏移- Returns:
- int
-
toInt
public static int toInt(byte[] b, int offset)把字节数组转换成int- Parameters:
b- 字节数组offset- 偏移- Returns:
- int
-
toBytes
public static byte[] toBytes(short s)
转换short变成字节数组- Parameters:
s- short类型- Returns:
- 字节数组
-
toShort
public static short toShort(byte[] b)
把字节数组转换成short- Parameters:
b- 字节数组- Returns:
- short
-
toShort
public static short toShort(byte[] b, int offset)把字节数组转换成short- Parameters:
b- 字节数组offset- 偏移- Returns:
- short
-
toBytes
public static byte[] toBytes(char c)
转换char变成字节数组- Parameters:
c- char类型- Returns:
- 字节数组
-
toChar
public static char toChar(byte[] b)
把字节数组转换成char- Parameters:
b- 字节数组- Returns:
- char
-
toChar
public static char toChar(byte[] b, int offset)把字节数组转换成char- Parameters:
b- 字节数组offset- 偏移- Returns:
- char
-
toBytes
public static byte[] toBytes(float f)
转换float变成字节数组- Parameters:
f- float类型- Returns:
- 字节数组
-
toFloat
public static float toFloat(byte[] b)
把字节数组转换成float- Parameters:
b- 字节数组- Returns:
- float
-
toFloat
public static float toFloat(byte[] b, int offset)把字节数组转换成float- Parameters:
b- 字节数组offset- 偏移- Returns:
- float
-
toBytes
public static byte[] toBytes(double d)
转换double变成字节数组- Parameters:
d- double类型- Returns:
- 字节数组
-
toDouble
public static double toDouble(byte[] b)
把字节数组转换成double- Parameters:
b- 字节数组- Returns:
- double
-
toDouble
public static double toDouble(byte[] b, int offset)把字节数组转换成double- Parameters:
b- 字节数组offset- 偏移- Returns:
- double
-
toBytes
public static byte[] toBytes(long l)
转换long变成字节数组- Parameters:
l- long类型- Returns:
- 字节数组
-
toLong
public static long toLong(byte[] b)
把字节数组转换成long- Parameters:
b- 字节数组- Returns:
- long
-
toLong
public static long toLong(byte[] b, boolean high)把字节数组转换成long- Parameters:
b- 字节数组high- true 高位在前 false 低位在前- Returns:
- long
-
toLong
public static long toLong(byte[] b, int offset)把字节数组转换成long- Parameters:
b- 字节数组offset- 偏移- Returns:
- long
-
toLong
public static long toLong(byte[] b, int offset, boolean high)把字节数组转换成long- Parameters:
b- 字节数组offset- 偏移high- true 高位在前 false 低位在前- Returns:
- long
-
toBytes
public static byte[] toBytes(java.lang.String s)
转换String变成字节数组- Parameters:
s- String类型- Returns:
- 字节数组
-
toBytes
public static byte[] toBytes(java.lang.String s, boolean is)转换String变成字节数组- Parameters:
s- String类型is- 是否加上长度- Returns:
- 字节数组
-
toString
public static java.lang.String toString(byte[] b)
把字节数组转换成long- Parameters:
b- 字节数组- Returns:
- long
-
toString
public static java.lang.String toString(byte[] b, int offset)把字节数组转换成字符串- Parameters:
b- 字节数组offset- 偏移- Returns:
- 字符串
-
toString
public static java.lang.String toString(byte[] b, int offset, boolean is)把字节数组转换成字符串- Parameters:
b- 字节数组offset- 偏移is- 是否读取长度- Returns:
- 字符串
-
copy
public static byte[] copy(byte[] b, int offset, int len)拷贝字节数组- Parameters:
b- 字节数组offset- 偏移len- 长度- Returns:
- 字节数组
-
toBean
public static ByteArray toBean(ByteArray array, byte[] b)
把字节数组转换为ByteArray- Parameters:
array- ByteArray 对象b- 字节数组- Returns:
- ByteArray对象
-
toBean
public static ByteArray toBean(ByteArray array, byte[] b, int offset)
把字节数组转换为ByteArray- Parameters:
array- ByteArray 对象b- 字节数组offset- 偏移- Returns:
- ByteArray对象
-
toBean
public static ByteArray toBean(ByteArray array, byte[] b, int offset, int len)
把字节数组转换为ByteArray- Parameters:
array- ByteArray 对象b- 字节数组offset- 偏移len- 长度- Returns:
- ByteArray对象
-
toBinary
public static <B> B toBinary(byte[] b, java.lang.Class<B> c)读取字节数组变成对象- Type Parameters:
B- 泛型- Parameters:
c- 序列化类b- 字节数组- Returns:
- 对象
-
add
public static byte[] add(byte[]... bs)
字节数组相连- Parameters:
bs- 字节数组- Returns:
- 相连后的数组
-
-