Skip to content

Instantly share code, notes, and snippets.

@28
Last active October 20, 2016 10:27
Show Gist options
  • Select an option

  • Save 28/55272ff12f3b07a098e800c4a8250cd6 to your computer and use it in GitHub Desktop.

Select an option

Save 28/55272ff12f3b07a098e800c4a8250cd6 to your computer and use it in GitHub Desktop.
A code snippet for reading stream and writting to file.
(defn write-to-file
[stream file-name]
(let [buff (byte-array 1024)]
(with-open [os (java.io.FileOutputStream. (java.io.File. file-name))]
(loop []
(let [size (.read stream buff)]
(when (> size 0)
(.write os buff 0 size)
(recur)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment