Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created February 3, 2011 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/941f9523212137c3a0ed to your computer and use it in GitHub Desktop.
Save sritchie/941f9523212137c3a0ed to your computer and use it in GitHub Desktop.
;; This version works great! The bytes match.
(defn input-stream
"Attempts to coerce the given argument to an input stream, allowing
for gzip format."
[arg]
(try
(GZIPInputStream. (io/input-stream arg))
(catch java.io.IOException e
(io/input-stream arg))))
;; this way, using the let macro, adds two random (or, at, least, unexpected)
;; bytes onto the front of the GZIPInputStream.
(defn input-stream
"Attempts to coerce the given argument to an input stream, allowing
for gzip format."
[arg]
(let [instream (io/input-stream arg)]
(try
(GZIPInputStream. instream)
(catch java.io.IOException e
instream))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment