Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Base64 Error while using decode

Tags:

android

base64

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
like image 942
Limpfro Avatar asked Jul 30 '26 14:07

Limpfro


1 Answers

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

I hope it helps you.

like image 199
Sejal Baraiya Avatar answered Aug 01 '26 07:08

Sejal Baraiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!