Félix López
2016-01-12 06:38:11 UTC
Hi there,
Is it possible to convert a file to a stream?
I have this code:
(def stoken (gloss/string :utf-8 :delimiters "«"))
(defcodec record-codec [stoken stoken])
(defn read-from-file [offset]
(let [raf (RandomAccessFile. (:db_file conf) "r")
buf (byte-array 4096)
_ (.seek raf offset)
n (.read raf buf)]
(.close raf)
(decode record-codec (java.nio.ByteBuffer/wrap buf) false)))
This method has the problem that I'm only reading 4096, I'm going to change
this method to read the file one byte a at time until I reach the
delimiters and I'm wondering if it would be possible to convert the file to
a stream
and then use decode-stream.
Thanks, Félix
Is it possible to convert a file to a stream?
I have this code:
(def stoken (gloss/string :utf-8 :delimiters "«"))
(defcodec record-codec [stoken stoken])
(defn read-from-file [offset]
(let [raf (RandomAccessFile. (:db_file conf) "r")
buf (byte-array 4096)
_ (.seek raf offset)
n (.read raf buf)]
(.close raf)
(decode record-codec (java.nio.ByteBuffer/wrap buf) false)))
This method has the problem that I'm only reading 4096, I'm going to change
this method to read the file one byte a at time until I reach the
delimiters and I'm wondering if it would be possible to convert the file to
a stream
and then use decode-stream.
Thanks, Félix
--
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Aleph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aleph-lib+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.