[英]Illegal Argument Exception: Illegal base64 character 3a when decoding String value using Base64.getDecode()
我正在解码的字符串值是“ ed:1234”,但它抛出IllegalArgumentException错误。 如果有人知道为什么我会出现此错误,将不胜感激。
码:
String authInfo = "ed:1234";
byte[] bytes = Base64.getDecoder().decode(authInfo);
错误:
java.lang.IllegalArgumentException: Illegal base64 character 3a
问题是:
(( ascii十进制58或十六进制3a)仅在(几种)Base64编码方案中有效,您需要Base64.getMimeDecoder()
。 喜欢,
byte[] bytes = Base64.getMimeDecoder().decode(authInfo);
System.out.println(Arrays.toString(bytes));
哪个输出(没有其他更改)
[121, -35, 118, -33]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.