Last active
October 20, 2016 10:27
-
-
Save 28/55272ff12f3b07a098e800c4a8250cd6 to your computer and use it in GitHub Desktop.
A code snippet for reading stream and writting to file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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