• (writer x & opts)
Attempts to coerce its argument into an open java.io.Writer.
Default implementations always return a java.io.BufferedWriter.

Default implementations are provided for Writer, BufferedWriter,
OutputStream, File, URI, URL, Socket, and String.

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 Writer is properly
closed.

1 Example top

  • (defn write-file []
      (with-open [w (clojure.java.io/writer  "f:/w.txt" :append true)]
        (.write w (str "hello" "world"))))
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:98 top

(defn ^Writer writer
  "Attempts to coerce its argument into an open java.io.Writer.
   Default implementations always return a java.io.BufferedWriter.

   Default implementations are provided for Writer, BufferedWriter,
   OutputStream, File, URI, URL, Socket, and String.

   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 Writer is properly
   closed."
  {:added "1.2"}
  [x & opts]
  (make-writer x (when opts (apply hash-map opts))))
Vars in clojure.java.io/writer:
Used in 0 other vars

Comments top

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