我正在尝试使用 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
一样?
最佳答案
decodeBase64是一个静态java方法。以下是在 Clojure 中的调用方式:
(import '[org.apache.commons.codec.binary Base64 Hex])
(Base64/decodeBase64 "s")
关于java - 使用 Clojure 中的 Apache Commons 编解码器解码Base64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19217986/