Created
May 3, 2020 23:14
-
-
Save RutledgePaulV/9e2acf373521fdd7a118d297ed64feb7 to your computer and use it in GitHub Desktop.
teed-writer.clj
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
(defn teed-writer [^Writer source ^Writer fork] | |
(proxy [Writer] [] | |
(write | |
([c] | |
(cond | |
(int? c) | |
(do (.write source (int c)) | |
(.write fork (int c))) | |
(string? c) | |
(do (.write source ^String c) | |
(.write fork ^String c)) | |
:otherwise | |
(do (.write source ^chars c) | |
(.write fork ^chars c)))) | |
([c offset length] | |
(cond | |
(string? c) | |
(do (.write source ^String c (int offset) (int length)) | |
(.write fork ^String c (int offset) (int length))) | |
:otherwise | |
(do (.write source ^chars c (int offset) (int length)) | |
(.write fork ^chars c (int offset) (int length)))))) | |
(flush [] | |
(.flush source) | |
(.flush fork)) | |
(close [] | |
(.close source) | |
(.close fork)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment