Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use java.nio in do-copy method for Files

NIO Channels reduce CPU/Disk load when copying Files (by using
syscalls like sendfile internally on Linux/Solaris).
  • Loading branch information...
commit 2b5ab103cbcfe6c49236ac6966c032d3c922233d 1 parent 5fc75df
@juergenhoetzel authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/clj/clojure/java/io.clj
View
7 src/clj/clojure/java/io.clj
@@ -334,9 +334,10 @@
(do-copy in output opts)))
(defmethod do-copy [File File] [#^File input #^File output opts]
- (with-open [in (FileInputStream. input)
- out (FileOutputStream. output)]
- (do-copy in out opts)))
+ (with-open [in (-> input FileInputStream. .getChannel)
+ out (-> output FileOutputStream. .getChannel)]
+ (.transferTo in 0 (.size in) out))
+ nil)
(defmethod do-copy [String OutputStream] [#^String input #^OutputStream output opts]
(do-copy (StringReader. input) output opts))
Please sign in to comment.
Something went wrong with that request. Please try again.