base32 decode to UTF in java

574 Views Asked by At

I want to decode a string to UTF-8 format in java. In the following code, I am able to get the expected decoded value from String decoded.

String s = "SFSFSFSFSF";
Base32 codec = new Base32();
String encoded = codec.encodeAsString(s.toUpperCase().getBytes());
Charset UTF_8 = Charset.forName("UTF-8");
String decoded =new String(codec.decode(encoded),UTF_8); // SFSFSFSFSF
String decoded2 = codec.decode(encoded); // [B@133314b

However, in my implementation specifically, I want to get the decoded val "SFSFSFSFSF" just by saying codec.decode(encoded) which is demonstrated in String decoded2 in the code. I want to know how I can achieve this by changing the way the String is encoded.

0

There are 0 best solutions below