Java Encode file to Base64 string To match with other encoded string(Java 将文件编码为 Base64 字符串以与其他编码字符串匹配)
问题描述
当我试图匹配两个编码字符串时,我得到一个不匹配的结果.请建议将文件编码为 base64 的方法,以匹配从其他来源找到的编码字符串.我尝试过使用 StandardCharsets.UTF_8
和 StandardCharsets.US_ASCII
.
您已经在使用 apache commons-codec,所以我建议添加 commons-io 来读取文件.这样你就可以删除你的 loadFile() 方法,只需要:
// to get encode string
// encoded string is :
//encoded string from file using some other source.
When i am trying to match both the encoded string , i am getting a missmatch.
please suggest method for encode file to base64 to match encoded string found from other source.
i have tried with StandardCharsets.UTF_8
and StandardCharsets.US_ASCII
.
You already using apache commons-codec so I recommend adding commons-io for reading the file. That way you can remove your loadFile() method and just have:
这篇关于Java 将文件编码为 Base64 字符串以与其他编码字符串匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!