Back
make-reader (clj)
(source)protocol
(make-reader x opts)
Creates a BufferedReader. See also IOFactory docs.
Examples
defold/defold
(ns util.text-util-test
(:require [clojure.java.io :as io]
[clojure.test :refer :all]
[util.text-util :as text-util])
(:import [org.apache.commons.io IOUtils]))
(deftest guess-line-endings-test
(let [make-reader (fn [^String content]
(some-> content IOUtils/toInputStream (io/make-reader nil)))]
(are [expected content]
(= expected (text-util/guess-line-endings (make-reader content)))
(deftest scan-line-endings-test
(let [make-reader (fn [^String content]
(some-> content IOUtils/toInputStream (io/make-reader nil)))]
(are [expected content]
(= expected (text-util/scan-line-endings (make-reader content)))
metosin/muuntaja
(ns muuntaja.protocols
(:require [clojure.java.io :as io]
[muuntaja.util :as util])
(:import (clojure.lang IFn AFn)
(java.io ByteArrayOutputStream ByteArrayInputStream InputStreamReader BufferedReader InputStream Writer OutputStream FileInputStream File)))
(extend StreamableResponse
io/IOFactory
(assoc io/default-streams-impl
:make-input-stream (fn [^StreamableResponse this _]
(with-open [out (ByteArrayOutputStream. 4096)]
((.f this) out)
(ByteArrayInputStream.
(.toByteArray out))))
:make-reader (fn [^StreamableResponse this _]
(with-open [out (ByteArrayOutputStream. 4096)]
((.f this) out)
(BufferedReader.
(InputStreamReader.
(ByteArrayInputStream.
(.toByteArray out))))))))
aliostad/deep-learning-lang-detection
(ns muuntaja.protocols
(:require [clojure.java.io :as io]
ring.core.protocols)
(:import (clojure.lang IFn AFn)
(java.io ByteArrayOutputStream ByteArrayInputStream InputStreamReader BufferedReader InputStream Writer)))
(extend StreamableResponse
io/IOFactory
(assoc io/default-streams-impl
:make-input-stream (fn [^StreamableResponse this _]
(with-open [out (ByteArrayOutputStream. 4096)]
((.f this) out)
(ByteArrayInputStream.
(.toByteArray out))))
:make-reader (fn [^StreamableResponse this _]
(with-open [out (ByteArrayOutputStream. 4096)]
((.f this) out)
(BufferedReader.
(InputStreamReader.
(ByteArrayInputStream.
(.toByteArray out))))))))