-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathonjava.clj
40 lines (36 loc) · 945 Bytes
/
onjava.clj
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
33
34
35
36
37
38
39
40
(let [s (new java.util.HashSet)]
(doto s
(.add 1)
(.add 2)
(.add 3))
(println (System/currentTimeMillis))
(println (.contains s 1))
(println (.contains s 5)) )
(let [l (new java.util.ArrayList)]
(doto l
(.add 1)
(.add 2)
(.add 3))
(println (map inc l)))
(defn make-a-class []
(proxy
[java.util.ArrayList java.util.concurrent.Callable]
[12]
(call [] (clojure.string/join "::" this))
(toString [] (str "A Callable ArrayList")) ))
(let [l (make-a-class)]
(doto l
(.add 1)
(.add 2)
(.add 3)
(.add 4))
(println (.call l))
(println (.toString l))
(println (.getClass l)) )
(let [fos (new java.io.FileOutputStream "/Users/oscar/hello.gz")
gzipOS (new java.util.zip.GZIPOutputStream fos)
osWriter (new java.io.OutputStreamWriter gzipOS "UTF-8")
writer (new java.io.BufferedWriter osWriter)]
(doto writer
(.append "Hello world !" )
(.close)))