output-stream

clojure.java.io

  • (output-stream x & opts)
Attempts to coerce its argument into an open java.io.OutputStream.
Default implementations always return a java.io.BufferedOutputStream.

Default implementations are defined for OutputStream, File, URI, URL,
Socket, and String arguments.

If the argument is a String, it tries to resolve it first as a URI, then
as a local file name. URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the OutputStream is
properly closed.

1 Example top

  • (:use [clojure.java.io :only [output-stream]])
    
    (defn use-output-stream []
      (with-open [o (output-stream "test.txt")]
        (.write o 65))) ; Writes 'A'
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:132 top

(defn ^OutputStream output-stream
  "Attempts to coerce its argument into an open java.io.OutputStream.
   Default implementations always return a java.io.BufferedOutputStream.

   Default implementations are defined for OutputStream, File, URI, URL,
   Socket, and String arguments.

   If the argument is a String, it tries to resolve it first as a URI, then
   as a local file name.  URIs with a 'file' protocol are converted to
   local file names.

   Should be used inside with-open to ensure the OutputStream is
   properly closed."
  {:added "1.2"}
  [x & opts]
  (make-output-stream x (when opts (apply hash-map opts))))
Vars in clojure.java.io/output-stream:
Used in 0 other vars

Comments top

No comments for output-stream. Log in to add a comment.