gpt4 book ai didi

java - 编译器似乎混淆了重载方法的两个版本。为什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:45:22 24 4
gpt4 key购买 nike

在我的jsp文件中有一行:

byte[] imageData = Base64.decodeBase64(request.getParameter("imageBase64"));

并且 eclipse 提示:

The method decodeBase64(byte[]) in the type Base64 is not applicable for the arguments (String)"

它表示该方法获取一个 String,但它需要一个 byte[]。但是在Base64 类中有两个重载版本的decodeBase64;一个带有参数 String,一个带有参数 byte[]

我不明白为什么编译器似乎认为我在调用 byte[] 版本时使用了不正确的 String 参数,而它本应使用 没有任何编译错误的字符串版本。

最佳答案

org.apache.commons.codec.binary 中的

Base64 类有2 个解码方法

static byte[]   decodeBase64(byte[] base64Data) since beginning

static byte[] decodeBase64(String base64String) since version 1.4.

我认为你的类路径中一定有 commons codec 1.4 之前的 jar

希望对您有所帮助。

关于java - 编译器似乎混淆了重载方法的两个版本。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13252393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com