Created
December 20, 2018 04:33
-
-
Save clonekim/fbc1754498a4eeff6cb4682dd24a194e to your computer and use it in GitHub Desktop.
clojure pipestream
This file contains 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
(let [in (java.io.PipedInputStream.) | |
out (java.io.PipedOutputStream.) | |
buf (java.io.BufferedWriter. (java.io.OutputStreamWriter. out))] | |
(.connect out in) | |
(doto buf | |
(.write "abdf") | |
(.write "abadfdf") | |
(.flush)) | |
(with-open [w (clojure.java.io/writer "stuff.txt")] | |
(loop [b (.read in)] | |
(when (< 0 (.available in)) | |
(.write w b) | |
(recur (.read in)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment