base32在java中解码为UTF

base32在java中解码为UTF,java,base64,decode,encode,base32,Java,Base64,Decode,Encode,Base32,我想用java将字符串解码为UTF-8格式。在下面的代码中,我能够从Stringdecoded中获得预期的解码值 String s = "SFSFSFSFSF"; Base32 codec = new Base32(); String encoded = codec.encodeAsString(s.toUpperCase().getBytes()); Charset UTF_8 = Charset.forName("UTF-8"); String dec

我想用java将字符串解码为UTF-8格式。在下面的代码中,我能够从
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

然而,在我的具体实现中,我想通过说
codec.decode(encoded)
来获得解码的val“
sfsfsf
”,这在代码中的
字符串
decoded2
中得到了演示。我想知道如何通过更改
字符串
的编码方式来实现这一点。

看起来您使用的Base32版本从
解码
返回的是
字节[]
,而不是
字符串
。要将
字节[]
转换为
字符串
没有比在
字符串解码
中更好的方法了。看起来您使用的Base32版本从
解码
返回的是
字节[]
,而不是
字符串
。要将
字节[]
转换为
字符串
,没有比在
字符串解码
中更好的方法了。