2013-10-07 26 views
0

我想使用Apache Commons Codec庫解碼Clojure中的base64字符串。從Clojure使用Apache Commons Codec decodeBase64

我能在圖書館使用這些方法:

(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一樣?

回答

4

decodeBase64是一種靜態Java方法。這裏是你如何在Clojure中稱呼它:

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