After perusing stackoverflow, it's evident to me that the "proper" way to
access a file within a jar is to use getResourceAsStream (as was mentioned
in the thread above, thank you), and I suppose clojure's io/input-stream
does the trick as well. Thanks, all!
--
You received this message bec
It seems my problem is related to this line in io.clj:
https://github.com/clojure/clojure/blob/f437b853adeaffc5cad9bb1e01e2355357a492c9/src/clj/clojure/java/io.clj#L60
(if (= "file" (.getProtocol u))
(as-file (escaped-utf8-urlstring->str
(.replace (.getFile u) \/ File/se
Here's my goal:
I have a thread that listens on a channel for tuples of [file-path,
file-contents] and writes files to a zip file using clojure.java.io/copy.
It's been really nice to be able to specify file-contents as anything
clojure.java.io/copy can consume, such as a byte[] or a String, and
I'm not sure anymore what your goal is exactly, but here is what I meant to
be complete:
(defn -main "I don't do a whole lot ... yet." [& args] (->> "hi.txt"
io/resource slurp (spit "out.txt")))
On Wed, Jan 28, 2015 at 4:57 PM, Dan Harbin wrote:
> Marshall,
>
> If I remove io/file, I get:
>
> E
Marshall,
If I remove io/file, I get:
Exception in thread "main" java.lang.IllegalArgumentException: No method in
multimethod 'do-copy' for dispatch value: [java.net.URL
java.io.OutputStreamWriter]
at clojure.lang.MultiFn.getFn(MultiFn.java:160)
at clojure.lang.MultiFn.invoke(Mu
On Monday, January 26, 2015 at 9:24:28 PM UTC-5, Dan Harbin wrote:
>
>
> io/file
>
>
Just delete that line. The `io/resource` function returns a URL which all
the Clojure IO functions can handle just fine-as is. When running in
development the URL happens to be a `file://` URL, and thus s
You may find value in reading this:
From:
http://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html
> Methods in the classes Class and ClassLoader provide a
location-independent way to locate resources.
On Tuesday, January 27, 2015 at 9:12:23 AM UTC-5, Benjamin VanRyseghem
wrot
The code can be found here:
https://github.com/teamwall/teamwall/blob/develop/src/server/teamwall/api.clj#L85
Here I used to do something like `io/as-file path-to-my-file`
but it failed because it’s not resolved as a file anymore when it’s jarred
Good luck,
Ben
On Tue, Jan 27, 2015 at 2:0
Ben, I would appreciate it if you'd show me the sample code. Thanks for
your help, everyone!
On Tuesday, January 27, 2015 at 6:28:59 AM UTC-6, Benjamin VanRyseghem
wrote:
>
> I face something similar.
>
> The issue was that inside a jar file, a resource is not a java.io.File
> anymore.
>
> I c
I face something similar.
The issue was that inside a jar file, a resource is not a java.io.File anymore.
I could turn around using an InputStream (I was in the case I wanted to serve a
resource via http-kit)
If you want more info, I can point you to the code where I use it
Hope it
Hi Dan,
Not sure if there are better options, but I know `slurp` does work on
resources in jars. You could (ab)use `spit` to do the copying.
HTH,
Jeroen
On Tue, Jan 27, 2015 at 3:24 AM, Dan Harbin wrote:
> I've created a sample project at Github[1] to demonstrate the problem I'm
> facing with
11 matches
Mail list logo