Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns clj-net.core
- (:gen-class)
- (:import [java.net URLConnection URL]
- [java.io InputStream InputStreamReader BufferedReader]))
- (defn -get [this, host]
- (let [connection (.openConnection (URL. host))]
- (.setRequestMethod connection "GET")
- (.connect connection)
- (with-open [stream (BufferedReader.
- (InputStreamReader. (.getInputStream connection)))]
- (.toString (reduce #(.append %1 %2)
- (StringBuffer.) (line-seq stream))))))
- (defn -main [this]
- (prn(-get this "https://www.google.com")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement