I want to learn how to change the value of a variable declared in a binding of a Clojure function binding. Below is the code I'm using. I want the function to return a java.lang.String object that contains the text contained in the string.
(defn read-text-from-file
{:doc "fn read-text-from-file is used to output in \"string\"
format the text in a file."}
[
(let [buff-reader (open-file-reader file-name)]
(loop [full-text "" line (.readLine buff-reader)]
(when line
(-> full-text (.concat line))
; (println full-text)
(recur (-> file-name (.concat line)) (.readLine buff-reader))))))
Note . The open-file-reader function is below:
(defn open-file-reader
{:doc "This is used to open a file, ready for reading"}
[file-name]
(let [file-object (java.io.File. file-name)
buff-reader (-> file-object (java.io.FileReader.)
(java.io.BufferedReader.))]
buff-reader))
Phil source
share