Additional copy methods for URLs in clojure.java.io

9 views
Skip to first unread message

mrBliss

unread,
Sep 3, 2010, 9:05:27 AM9/3/10
to Clojure
Hi,
I was wondering why there aren't versions of the copy method in
clojure.java.io that handle URLs as input. I have needed, written and
reused them several times now.

So I thought it would be a good idea to include them in
clojure.java.io.

Adding the following methods and updating the docstring for copy would
do the trick:


(defmethod do-copy [URL OutputStream] [^URL input ^OutputStream output
opts]
(with-open [in (-> input .openStream BufferedInputStream.)]
(do-copy in output opts)))

(defmethod do-copy [URL Writer] [^URL input ^Writer output opts]
(with-open [in (-> input .openStream BufferedInputStream.)]
(do-copy in output opts)))

(defmethod do-copy [URL File] [^URL input ^File output opts]
(with-open [in (-> input .openStream BufferedInputStream.)]
(do-copy in output opts)))


Thanks,
mrBliss
Reply all
Reply to author
Forward
0 new messages