I too stumbled upon this a while ago. I might even say that on some
level it's so simple that there is not much documentation about it, and
at some point it gets 'complex' enough that you should know about java
enough.

The simplest way is to slurp or spit. slurp reads a file into a string,
and spit writes a string into a file.

Then there is the with-open macro(?) which opens connections and closes
them when one. The reader and writer opens a java Reader and Writer
classes respectively. (They're interfaces, but those functions try to
figure out what kind of handle you're trying to open). Also the
output-stream and input-stream handle it a bit.

(with-open [r (reader "http://www.reddit.com";)]
 (.read r))

And to finish this off with a shameless plug; I wrote a blog post about
downloading a random wallpaper from reddit, which handles reading http
content, parsing json and reading/writing binary files.

http://users.utu.fi/machra/posts/2011-08-24-2-reddit-clojure.html

-- 
Mats Rauhala
MasseR

Attachment: pgp9yGpYZlu52.pgp
Description: PGP signature

Reply via email to