byte与base64字串换转
byte[] 转字符串的话需要转化为base64的字符串才能可逆。
public byte[] base64ToByte(String strBase64){
if(strBase64==null)return null;
byte[] bytes = null;
try {
BASE64Decoder dec = new BASE64Decoder();
bytes = dec.decodeBuffer(strBase64);
}
catch(Exception ex){
ex.printStackTrace();
}
return bytes;
}
public String byteToBase64(byte[] aryByte){
if(aryByte==null)return "";
String strBase64 = "";
try {
BASE64Encoder enc = new BASE64Encoder();
strBase64 = enc.encode(aryByte);
}
catch(Exception ex){
ex.printStackTrace();
}
return strBase64;
}