I tried my best to read the contents of the resource directory in my lein project. Now I understand (after incorrect use) to use clojure.java.io/resource to pull out a resource, because just using the file system does not work when it is packaged like a jar:
> (require '[clojure.java.io :as io]) > (def zipzip (.openStream (io/resource "zip.zip")))
This returns a BufferedInputStream
. I want to make this zip file and unzip it to a local directory. I cannot make a ZipFile
from it, but I can make a ZipInputStream
. Unfortunately, although I can get ZipEntries
from this, I need a ZipFile
to really read the contents of ZipEntry
. I can do it:
> (-> zipzip ZipInputStream. .getNextEntry .getName)
This returns the name, but there is nothing in the api docs to get the actual contents of this ZipEntry
using ZipInputStream
!
How to write contents from this ZipInputStream
to a local directory? (this also works when the code is packaged in a jar!)
source share