我的代码:
private static String convertToBase64(String string)
{
final byte[] encodeBase64 =
org.apache.commons.codec.binary.Base64.encodeBase64(string
.getBytes());
System.out.println(Hex.encodeHexString(encodeBase64));
final byte[] data = string.getBytes();
final String encoded =
javax.xml.bind.DatatypeConverter.printBase64Binary(data);
System.out.println(encoded);
return encoded;
}
现在我调用它:convertToBase64("stackoverflow");
并得到以下结果:
6333526859327476646d56795a6d787664773d3d
c3RhY2tvdmVyZmxvdw==
为什么我得到不同的结果?