I want to redirect the standard input in my Clojure benchmark. I have passed the file as an argument and I am trying to find the equivalant code in java: System.setIn(new FileInputStream(filename)); but for Clojure.
The main issue is that I use the DaCapo suite to calculate the performance of Benchmark and the method that loads the benchmark does not recognize special characters like "<" in contrast to the cmd (running the benchmark's jar directly from the cmd..).
This is what I am trying to do..but still does not work.. I think that br has the standard input from the in and it is used by the rest of the program. How can I change the in while I have in the args the desired path, so I can run the benchmark correctly? This is my effort with the "system/setin"
(defn -main [& args]
(let [max-dna-chars-per-line 60
jk (with-open [is (clojure.java.io/input-stream (first args))]
(System/setIn is))
br (java.io.BufferedReader. *in*)
bw (java.io.BufferedWriter. *out* (* 16 8192)) ; 16 * default size, I think
;; We could use the map complement-dna-char-map instead of
;; complement-dna-char-fn, but when I tested that, the program
;; spent a lot of time running the hashCode method on
;; characters. I'm hoping this is faster.
complement-dna-char-vec (make-vec-char-mapper complement-dna-char-map)]
(loop [[desc-str dna-seq-str more] (fasta-slurp-br br)]
(println-string-to-buffered-writer bw desc-str)
(print-reverse-complement-of-str-in-lines bw dna-seq-str
complement-dna-char-vec
max-dna-chars-per-line)
(when more
(recur (fasta-slurp-br br))))
(. bw flush)))