I need to convert Nippy data structures stored on disk into something that can be read by Nippy? Nippy uses byte arrays, so I need some way to convert the file into a byte a
Since you know the .length of the file, you can allocate once and use DataInputStream's readFully method. No additional libraries, buffer copies, or loops required.
(defn file-to-byte-array
[^java.io.File file]
(let [result (byte-array (.length file))]
(with-open [in (java.io.DataInputStream. (clojure.java.io/input-stream file))]
(.readFully in result))
result))