byte[] key = "abc".getBytes(); String str = (new BASE64Encoder()).encodeBuffer(key); System.out.println("【"+str+"】");
上面代码产生的字符串带有换行符“ ” ,与其他字符拼接时会产生换行的字符串(多行)
/share_page3.htm?invited=ovLzEwLjUwLj &invitedname=R0cDovLzEwLjUwLjExNS4
应该为(一行):
/share_page3.htm?invited=ovLzEwLjUwLj&invitedname=R0cDovLzEwLjUwLjExNS4
解决方法:
public static String encryptBASE64(byte[] key){ return (new BASE64Encoder()).encode(key); }