Java - decode address from app global state

Hi everybody; i’ve deployed an ARC4 ABI-compliant SC which stores a 32-bytes string (actually an address) in global state; i tried to read the value from my Java Spring backend, unsuccessfully. Actually, the java sdk has not a method to encode address from base64 decoded value.bytes, as javascript does with ‘algosdk.encodeAddress()’. Could anyone help?

You need to use the Address class:

I’ve already tried to istantiate a new Address by passing value.bytes but unsuccessfully. Could you explane me how to do so?

You need to decode the base64 into a 32-byte array.
I’ve not tested but something like:

byte[] decodedBytes = Base64.getDecoder().decode(globalStateAddress);
Address addr = new Address(decodedBytes);
String addrAsString = addr.encodeAsString();

yeah, it works! don’t know why, but i’ve done something similar (maybe using algosdk.Encoder) and it didn’t work. Thanks a lot!!!