How do I know the allowed options for the Clojure function (spit)?

The Clojure -function function spitallows you to write data to files, for example:

(spit "filename.txt" "content")

It also allows you to add content to existing files.

(spit "filename.txt" "content" :append true)

The documentation ( (doc spit)) only says that options can be passed in clojure.java.io/writer. But (doc clojure.java.io/writer)does not list the allowed parameters. So, is there a “verbose mode” for documentation?

I found :append-option via http://clojuredocs.org/clojure.core/spit , but I'm sure it is also listed somewhere in the documentation.

+4
source share
2 answers

, Java.

http://docs.oracle.com/javase/tutorial/essential/io/file.html

, , :encoding

https://github.com/clojure/clojure/blob/clojure-1.6.0/src/clj/clojure/java/io.clj#L74-L77

Common options include

 :append    true to open stream in append mode
 :encoding  string name of encoding to use, e.g. \"UTF-8\".

, Java , ,

+2

clojure.java.io/writer make-writer, io.clj;

(defprotocol ^{:added "1.2"} IOFactory
  "Factory functions that create ready-to-use, buffered versions of
  the various Java I/O stream types, on top of anything that can
  be unequivocally converted to the requested kind of stream.
  Common options include

   :append    true to open stream in append mode
   :encoding  string name of encoding to use, e.g. \"UTF-8\".
  Callers should generally prefer the higher level API provided by
  reader, writer, input-stream, and output-stream."
  (^{:added "1.2"} make-reader [x opts] "Creates a BufferedReader. See also IOFactory docs.")
  (^{:added "1.2"} make-writer [x opts] "Creates a BufferedWriter. See also IOFactory docs.")
  (^{:added "1.2"} make-input-stream [x opts] "Creates a BufferedInputStream. See also IOFactory docs.")
  (^{:added "1.2"} make-output-stream [x opts] "Creates a BufferedOutputStream. See also IOFactory docs."))

@Edward, :append :encoding

@Jaime , : - (.

+1