我正在尝试将字节转换为base64字符串,并且在得到的字符串中我得到 \ n ,如果没有这些转义序列,如何获得base64结果,我知道我可以从字符串中删除它们但关键是为什么它要广告这些额外的字符。
这就是我将字节转换为base64字符串的方式
/*
* Convert bytes to Base64
*/
public static String convertBytesToBase64(byte[] bytes) {
return new String(Base64.encode(bytes, 0));
}
答案 0 :(得分:1)
Base64.NO_WRAP编码器标志位,以省略所有行终止符(即,输出将在一条长行上)。
public static String convertBytesToBase64(byte[] bytes) {
return new String(Base64.encodeToString(bytes,Base64.NO_WRAP));
}