Г
Size: a a a
Г
PP
VM
Г
Г
(defn chunk-file-on-n-sized-bytes-arrays [filename n]
(let [file (io/file filename)
l (.length file)
tmp (byte-array n)]
(with-open [r (io/input-stream file)]
(loop [result []
offset 0]
(if (> offset l)
result
(do (.read r tmp offset n)
(recur
(conj result tmp)
(+ offset n))))))))
PP
(defn chunk-file-on-n-sized-bytes-arrays [filename n]
(let [file (io/file filename)
l (.length file)
tmp (byte-array n)]
(with-open [r (io/input-stream file)]
(loop [result []
offset 0]
(if (> offset l)
result
(do (.read r tmp offset n)
(recur
(conj result tmp)
(+ offset n))))))))
Г
PP
PP
Г
Г
PP
Г
PP
Г
Г
ST
(defn read-bytes
[filename, n-bytes]
(let [file (io/file filename)
cbuf (char-array n-bytes)]
(with-open [r (io/reader file)]
(.read r cbuf 0 n-bytes)
(seq cbuf))))
read
можно проще написать(defn read-bytes
[filename, n-bytes]
(let [file (io/file filename)
cbuf (char-array n-bytes)]
(with-open [r (io/reader file)]
(.read r cbuf)
(seq cbuf))))
ST
PP