小智 13
最简洁的方法就是使用字节流库,您只需调用它(byte-streams/to-byte-array (java.io.File. "path")).
如果你想在没有外部库的情况下这样做,它将是这样的:
(let [f (java.io.File. "path")
ary (byte-array (.length f))
is (java.io.FileInputStream. f)]
(.read is ary)
(.close is)
ary)
Run Code Online (Sandbox Code Playgroud)