• (copy input output & opts)
Copies input to output. Returns nil or throws IOException.
Input may be an InputStream, Reader, File, byte[], or String.
Output may be an OutputStream, Writer, or File.

Options are key/value pairs and may be one of

:buffer-size buffer size to use, default is 1024.
:encoding encoding to use if converting between
byte and char streams.

Does not close any streams except those it opens itself
(on a File).

1 Example top

  • (ns your-project
      (:require [clojure.java.io :as io]))
    
    (defn copy-file [source-path dest-path]
      (io/copy (io/file source-path) (io/file dest-path)))
    
    (copy-file "/home/username/squirrel.txt" "/home/username/burt-reynolds.txt")
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/java/io.clj:368 top

(defn copy
  "Copies input to output.  Returns nil or throws IOException.
  Input may be an InputStream, Reader, File, byte[], or String.
  Output may be an OutputStream, Writer, or File.

  Options are key/value pairs and may be one of

    :buffer-size  buffer size to use, default is 1024.
    :encoding     encoding to use if converting between
                  byte and char streams.   

  Does not close any streams except those it opens itself 
  (on a File)."
  {:added "1.2"}
  [input output & opts]
  (do-copy input output (when opts (apply hash-map opts))))
Vars in clojure.java.io/copy:
Used in 0 other vars

Comments top

No comments for copy. Log in to add a comment.