Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
--- a/src/clj/clojure/java/io.clj
+++ b/src/clj/clojure/java/io.clj
@@ -18,7 +18,7 @@
StringReader ByteArrayInputStream
BufferedInputStream BufferedOutputStream
CharArrayReader Closeable)
- ( URI URL MalformedURLException Socket)))
+ ( URI URL URLDecoder MalformedURLException Socket)))
^{:doc "Type object for a Java primitive byte array."
@@ -47,13 +47,13 @@
(as-file [f] f)
- (as-url [f] (.toURL f))
+ (as-url [f] (.toURL (.toURI f)))
(as-url [u] u)
(as-file [u]
(if (= "file" (.getProtocol u))
- (as-file (.getPath u))
+ (as-file (URLDecoder/decode (.getPath u)))
(throw (IllegalArgumentException. (str "Not a file: " u)))))
@@ -229,11 +229,11 @@
:make-input-stream (fn [^URL x opts]
(if (= "file" (.getProtocol x))
- (FileInputStream. (.getPath x))
+ (FileInputStream. (as-file x))
(.openStream x)) opts))
:make-output-stream (fn [^URL x opts]
(if (= "file" (.getProtocol x))
- (make-output-stream (File. (.getPath x)) opts)
+ (make-output-stream (as-file x) opts)
(throw (IllegalArgumentException. (str "Can not write to non-file URL <" x ">")))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.