【问题标题】:Using Apache Commons Codec decodeBase64 from Clojure使用 Clojure 中的 Apache Commons Codec decodeBase64
【发布时间】:2023-03-25 21:53:01
【问题描述】:

我正在尝试使用 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 (Base64.) "s") 一样使用decodeBase64 时,我得到了

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

我做错了什么?看来我应该可以打电话给decodeBase64,就像我可以打电话给decode一样?

【问题讨论】:

    标签: java clojure interop hex base64


    【解决方案1】:

    decodeBase64 是一个静态 java 方法。在 Clojure 中是这样称呼它的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-12
      • 2012-11-05
      • 2017-10-16
      • 2011-01-04
      • 2012-08-30
      • 2017-04-18
      • 2020-09-03
      相关资源
      最近更新 更多