Reputation: 2828
I am trying to convert bytes to base64 String and in the resultant string i am getting \n, how can i get base64 result without these escape sequences, i know i can remove them from the string but the point is why does it ad these extra characters.
That's how i am converting my bytes to base64 string
/*
* Convert bytes to Base64
*/
public static String convertBytesToBase64(byte[] bytes) {
return new String(Base64.encode(bytes, 0));
}
Upvotes: 0
Views: 157
Reputation: 3976
Base64.NO_WRAP Encoder flag bit to omit all line terminators (i.e., the output will be on one long line).
public static String convertBytesToBase64(byte[] bytes) {
return new String(Base64.encodeToString(bytes,Base64.NO_WRAP));
}
Upvotes: 2