Advertisement
Guest User

LMAO

a guest
Mar 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns clj-net.core
  2.   (:gen-class)
  3.   (:import [java.net URLConnection URL]
  4.            [java.io InputStream InputStreamReader BufferedReader]))
  5.  
  6. (defn -get [this, host]
  7.   (let [connection (.openConnection (URL. host))]
  8.     (.setRequestMethod connection "GET")
  9.     (.connect connection)
  10.     (with-open [stream (BufferedReader.
  11.                         (InputStreamReader. (.getInputStream connection)))]
  12.       (.toString (reduce #(.append %1 %2)
  13.                           (StringBuffer.) (line-seq stream))))))
  14.    
  15. (defn -main [this]
  16.   (prn(-get this "https://www.google.com")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement