Limpfro
Limpfro

Reputation: 177

Bad Base64 Error while using decode

I'm using the following code to encode a url and then decode it and use it in my project but i keep getting errors and the app crashes when i try to load a url on this code

any guidance is appreciated

private static String getURL() {
    String base64URL = "http://www.domain.dom/folder/folder2/2.json";
    byte[] data = Base64.decode(base64URL, Base64.NO_CLOSE);
    String text = new String(data, StandardCharsets.UTF_8);
    return text;}

Error:

java.lang.IllegalArgumentException: bad base-64

Upvotes: 3

Views: 9634

Answers (1)

Sejal Baraiya
Sejal Baraiya

Reputation: 238

Try this, Base64.NO_WRAP or Base64.NO_PADDING this both are working for me.

I hope it helps you.

Upvotes: 2

Related Questions