繁体   English   中英

使用Clojure的Apache Commons Codec解码Base64

[英]Using Apache Commons Codec decodeBase64 from Clojure

我正在尝试使用Apache Commons Codec库在Clojure中解码base64字符串。

我可以在库中使用以下方法:

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

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

但是,当我尝试使用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)

我究竟做错了什么? 好像我应该能够调用decodeBase64一样,就像我可以调用decode

encodeBase64是静态Java方法。 这是您在Clojure中的称呼方式:

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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM