简体   繁体   English

使用Clojure的Apache Commons Codec解码Base64

[英]Using Apache Commons Codec decodeBase64 from Clojure

I am trying to decode a base64 string in Clojure using the Apache Commons Codec library. 我正在尝试使用Apache Commons Codec库在Clojure中解码base64字符串。

I am able to use these methods in the library: 我可以在库中使用以下方法:

(ns decode.core
  (:import (org.apache.commons.codec.binary Base64 Hex))
  (:gen-class))

(.encode (Hex.) "s")
(.decode (Hex.) "0a")
(.decode (Base64.) "s")

But when I try to use decodeBase64 like (.decodeBase64 (Base64.) "s") I get 但是,当我尝试使用decodeBase64(.decodeBase64 (Base64.) "s")我得到

IllegalArgumentException No matching method found: decodeBase64 for class
org.apache.commons.codec.binary.Base64  clojure.lang.Reflector.invokeMatchingMethod
(Reflector.java:53)

What am I doing wrong? 我究竟做错了什么? It seems like I should be able to call decodeBase64 just like I can call decode ? 好像我应该能够调用decodeBase64一样,就像我可以调用decode

decodeBase64 is a static java method. encodeBase64是静态Java方法。 Here is how you call it in Clojure: 这是您在Clojure中的称呼方式:

 (import '[org.apache.commons.codec.binary Base64 Hex])
 (Base64/decodeBase64 "s")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DecodeBase64使用apache commons - DecodeBase64 using apache commons OutOfMemoryError 与 apache 公共 Base64 static 方法 decodeBase64 - OutOfMemoryError with apache commons Base64 static method decodeBase64 没有静态方法 decodeBase64 - Google 凭据 - No static method decodeBase64 - Google Credential Glassfish和Tomcat中的decodeBase64的不同结果 - Different results for decodeBase64 in Glassfish and Tomcat 无法使Base64.decodeBase64工作(通用编解码器) - Can't get Base64.decodeBase64 to work (Commons codec) 如何使用org.apache.commons.codec.binary.base64对Java对象进行Base64编码? - How to Base64 encode a Java object using org.apache.commons.codec.binary.base64? 类型为Base64的方法encodeBase64(byte [])不适用于参数(String) - The method decodeBase64(byte[]) in the type Base64 is not applicable for the arguments (String) 使用apache commons编解码器的Base64解码在非常大的二进制文件上失败 - Base64 decoding using apache commons codec failing on very large binary file 如何使用 apache.commons.codec Base64 解密 Java 客户端中的字符串(在 .NET 中加密)? - How to decrypt string (encrypted in .NET) in Java client using apache.commons.codec Base64? Android v1p1beta1语音-java.lang.NoSuchMethodError:无静态方法encodeBase64 - Android v1p1beta1 Speech - java.lang.NoSuchMethodError: No static method decodeBase64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM