Package org.apache.dubbo.common.io
Class Bytes
java.lang.Object
org.apache.dubbo.common.io.Bytes
CodecUtils.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]base642bytes(String str) from base64 string.static byte[]base642bytes(String str, char[] code) from base64 string.static byte[]base642bytes(String str, int offset, int length) from base64 string.static byte[]base642bytes(String str, int off, int len, char[] code) from base64 string.static byte[]base642bytes(String str, int off, int len, String code) from base64 string.static byte[]base642bytes(String str, String code) from base64 string.static Stringbytes2base64(byte[] b) to base64 string.static Stringbytes2base64(byte[] b, char[] code) to base64 string.static Stringbytes2base64(byte[] b, int offset, int length) to base64 string.static Stringbytes2base64(byte[] bs, int off, int len, char[] code) to base64 string.static Stringbytes2base64(byte[] b, int offset, int length, String code) to base64 string.static Stringbytes2base64(byte[] b, String code) to base64 string.static doublebytes2double(byte[] b) to long.static doublebytes2double(byte[] b, int off) to long.static floatbytes2float(byte[] b) to int.static floatbytes2float(byte[] b, int off) to int.static Stringbytes2hex(byte[] bs) to hex string.static Stringbytes2hex(byte[] bs, int off, int len) to hex string.static intbytes2int(byte[] b) to int.static intbytes2int(byte[] b, int off) to int.static longbytes2long(byte[] b) to long.static longbytes2long(byte[] b, int off) to long.static shortbytes2short(byte[] b) to short.static shortbytes2short(byte[] b, int off) to short.static byte[]copyOf(byte[] src, int length) byte array copy.static byte[]double2bytes(double v) to byte array.static voiddouble2bytes(double v, byte[] b) to byte array.static voiddouble2bytes(double v, byte[] b, int off) to byte array.static byte[]float2bytes(float v) to byte array.static voidfloat2bytes(float v, byte[] b) to byte array.static voidfloat2bytes(float v, byte[] b, int off) to byte array.static byte[]getMD5(byte[] source) get md5.static byte[]get md5.static byte[]getMD5(InputStream is) get md5.static byte[]get md5.static byte[]from hex string.static byte[]from hex string.static byte[]int2bytes(int v) to byte array.static voidint2bytes(int v, byte[] b) to byte array.static voidint2bytes(int v, byte[] b, int off) to byte array.static byte[]long2bytes(long v) to byte array.static voidlong2bytes(long v, byte[] b) to byte array.static voidlong2bytes(long v, byte[] b, int off) to byte array.static byte[]short2bytes(short v) to byte array.static voidshort2bytes(short v, byte[] b) to byte array.static voidshort2bytes(short v, byte[] b, int off) to byte array.static byte[]unzip(byte[] bytes) unzip.static byte[]zip(byte[] bytes) zip.
-
Method Details
-
copyOf
public static byte[] copyOf(byte[] src, int length) byte array copy.- Parameters:
src- src.length- new length.- Returns:
- new byte array.
-
short2bytes
public static byte[] short2bytes(short v) to byte array.- Parameters:
v- value.- Returns:
- byte[].
-
short2bytes
public static void short2bytes(short v, byte[] b) to byte array.- Parameters:
v- value.b- byte array.
-
short2bytes
public static void short2bytes(short v, byte[] b, int off) to byte array.- Parameters:
v- value.b- byte array.
-
int2bytes
public static byte[] int2bytes(int v) to byte array.- Parameters:
v- value.- Returns:
- byte[].
-
int2bytes
public static void int2bytes(int v, byte[] b) to byte array.- Parameters:
v- value.b- byte array.
-
int2bytes
public static void int2bytes(int v, byte[] b, int off) to byte array.- Parameters:
v- value.b- byte array.off- array offset.
-
float2bytes
public static byte[] float2bytes(float v) to byte array.- Parameters:
v- value.- Returns:
- byte[].
-
float2bytes
public static void float2bytes(float v, byte[] b) to byte array.- Parameters:
v- value.b- byte array.
-
float2bytes
public static void float2bytes(float v, byte[] b, int off) to byte array.- Parameters:
v- value.b- byte array.off- array offset.
-
long2bytes
public static byte[] long2bytes(long v) to byte array.- Parameters:
v- value.- Returns:
- byte[].
-
long2bytes
public static void long2bytes(long v, byte[] b) to byte array.- Parameters:
v- value.b- byte array.
-
long2bytes
public static void long2bytes(long v, byte[] b, int off) to byte array.- Parameters:
v- value.b- byte array.off- array offset.
-
double2bytes
public static byte[] double2bytes(double v) to byte array.- Parameters:
v- value.- Returns:
- byte[].
-
double2bytes
public static void double2bytes(double v, byte[] b) to byte array.- Parameters:
v- value.b- byte array.
-
double2bytes
public static void double2bytes(double v, byte[] b, int off) to byte array.- Parameters:
v- value.b- byte array.off- array offset.
-
bytes2short
public static short bytes2short(byte[] b) to short.- Parameters:
b- byte array.- Returns:
- short.
-
bytes2short
public static short bytes2short(byte[] b, int off) to short.- Parameters:
b- byte array.off- offset.- Returns:
- short.
-
bytes2int
public static int bytes2int(byte[] b) to int.- Parameters:
b- byte array.- Returns:
- int.
-
bytes2int
public static int bytes2int(byte[] b, int off) to int.- Parameters:
b- byte array.off- offset.- Returns:
- int.
-
bytes2float
public static float bytes2float(byte[] b) to int.- Parameters:
b- byte array.- Returns:
- int.
-
bytes2float
public static float bytes2float(byte[] b, int off) to int.- Parameters:
b- byte array.off- offset.- Returns:
- int.
-
bytes2long
public static long bytes2long(byte[] b) to long.- Parameters:
b- byte array.- Returns:
- long.
-
bytes2long
public static long bytes2long(byte[] b, int off) to long.- Parameters:
b- byte array.off- offset.- Returns:
- long.
-
bytes2double
public static double bytes2double(byte[] b) to long.- Parameters:
b- byte array.- Returns:
- double.
-
bytes2double
public static double bytes2double(byte[] b, int off) to long.- Parameters:
b- byte array.off- offset.- Returns:
- double.
-
bytes2hex
to hex string.- Parameters:
bs- byte array.- Returns:
- hex string.
-
bytes2hex
to hex string.- Parameters:
bs- byte array.off- offset.len- length.- Returns:
- hex string.
-
hex2bytes
from hex string.- Parameters:
str- hex string.- Returns:
- byte array.
-
hex2bytes
from hex string.- Parameters:
str- hex string.off- offset.len- length.- Returns:
- byte array.
-
bytes2base64
to base64 string.- Parameters:
b- byte array.- Returns:
- base64 string.
-
bytes2base64
to base64 string.- Parameters:
b- byte array.- Returns:
- base64 string.
-
bytes2base64
to base64 string.- Parameters:
b- byte array.code- base64 code string(0-63 is base64 char,64 is pad char).- Returns:
- base64 string.
-
bytes2base64
to base64 string.- Parameters:
b- byte array.code- base64 code string(0-63 is base64 char,64 is pad char).- Returns:
- base64 string.
-
bytes2base64
to base64 string.- Parameters:
b- byte array.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- base64 string.
-
bytes2base64
to base64 string.- Parameters:
bs- byte array.off- offset.len- length.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- base64 string.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.- Returns:
- byte array.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.offset- offset.length- length.- Returns:
- byte array.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- byte array.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.off- offset.len- length.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- byte array.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- byte array.
-
base642bytes
from base64 string.- Parameters:
str- base64 string.off- offset.len- length.code- base64 code(0-63 is base64 char,64 is pad char).- Returns:
- byte array.
-
zip
zip.- Parameters:
bytes- source.- Returns:
- compressed byte array.
- Throws:
IOException
-
unzip
unzip.- Parameters:
bytes- compressed byte array.- Returns:
- byte uncompressed array.
- Throws:
IOException
-
getMD5
get md5.- Parameters:
str- input string.- Returns:
- MD5 byte array.
-
getMD5
public static byte[] getMD5(byte[] source) get md5.- Parameters:
source- byte array source.- Returns:
- MD5 byte array.
-
getMD5
get md5.- Parameters:
file- file source.- Returns:
- MD5 byte array.
- Throws:
IOException
-
getMD5
get md5.- Parameters:
is- input stream.- Returns:
- MD5 byte array.
- Throws:
IOException
-