Class BytesUtil
java.lang.Object
com.github.tobato.fastdfs.domain.proto.mapper.BytesUtil
java与C服务端数据交换时byte数组与int,long转换的工具类
- Author:
- yuqih
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbuff2int(byte[] bs, int offset) buff convert to intstatic longbuff2long(byte[] bs, int offset) buff convert to longstatic byte[]long2buff(long n) long convert to buff (big-endian)static byte[]objString2Byte(String value, int max, Charset charset) 将String转换为bytestatic byte[]objString2Byte(String value, Charset charset) 将String转换为byte
-
Constructor Details
-
BytesUtil
public BytesUtil()
-
-
Method Details
-
long2buff
public static byte[] long2buff(long n) long convert to buff (big-endian)- Parameters:
n- long number- Returns:
- 8 bytes buff
-
buff2long
public static long buff2long(byte[] bs, int offset) buff convert to long- Parameters:
bs- the buffer (big-endian)offset- the start position based 0- Returns:
- long number
-
buff2int
public static int buff2int(byte[] bs, int offset) buff convert to int- Parameters:
bs- the buffer (big-endian)offset- the start position based 0- Returns:
- int number
-
objString2Byte
将String转换为byte- Returns:
- Throws:
NoSuchMethodExceptionInvocationTargetExceptionIllegalAccessException
-
objString2Byte
将String转换为byte- Parameters:
value-charset-- Returns:
-