1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
From: Alan Thompson <cloojure@gmail.com>
Description: Move away from sun.misc.Base64decoder
Origin: upstream, https://github.com/clj-commons/useful/pull/43
Bug: https://github.com/clj-commons/useful/issues/40
Index: useful-clojure/src/flatland/useful/compress.clj
===================================================================
--- useful-clojure.orig/src/flatland/useful/compress.clj
+++ useful-clojure/src/flatland/useful/compress.clj
@@ -1,17 +1,17 @@
(ns flatland.useful.compress
(:import [java.util.zip DeflaterOutputStream InflaterInputStream]
[java.io ByteArrayOutputStream ByteArrayInputStream]
- [sun.misc BASE64Decoder BASE64Encoder]))
+ [java.util Base64]))
-(defn smash [^String str]
+(defn smash [str]
(let [out (ByteArrayOutputStream.)]
(doto (DeflaterOutputStream. out)
(.write (.getBytes str))
(.finish))
- (-> (BASE64Encoder.)
- (.encodeBuffer (.toByteArray out)))))
+ (-> (Base64/getEncoder)
+ (.encode (.toByteArray out)))))
-(defn unsmash [^String str]
- (let [bytes (-> (BASE64Decoder.) (.decodeBuffer str))
+(defn unsmash [str]
+ (let [bytes (-> (Base64/getDecoder) (.decode str))
in (ByteArrayInputStream. bytes)]
(slurp (InflaterInputStream. in))))
|