0
考慮操作的順序如下:的Java NIO字符集編碼解碼
String pt = "abcd";
byte[] b64 = Base64.decodeBase64(pt.getBytes("UTF-8"));
ByteBuffer wrap = ByteBuffer.wrap(b64);
CharBuffer decode = StandardCharsets.UTF_8.decode(wrap);
ByteBuffer encode = StandardCharsets.UTF_8.encode(decode);
byte[] bytes = new byte[encode.remaining()];
encode.get(bytes);
String x = Base64.encodeBase64String(bytes); // "ae+/vR0="
爲什麼pt
和x
不相等?
我使用這些功能是否錯誤?到底是怎麼回事?