Skip to content

Instantly share code, notes, and snippets.

@angerman
Created December 3, 2009 21:16
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 angerman/248532 to your computer and use it in GitHub Desktop.
Save angerman/248532 to your computer and use it in GitHub Desktop.
(in-ns 'clojure.contrib.duck-streams)
(import '(java.io File RandomAccessFile))
;; copied and adapted from c.c.ds
(defmulti #^{:arglist '([x])} random-access-reader class)
(defmethod random-access-reader File [#^File x]
(RandomAccessFile. x "r"))
(defmethod random-access-reader String [#^String x]
(random-access-reader (file-str x)))
(defmethod random-access-reader :default [x]
(throw (Exception. (str "Cannot open " (pr-str x) " as a reader."))))
;; causes the problem when eveluated on the repl
; (let [raf (random-access-reader "/Users/angerman/upps.data.model")
; line (.readLine raf)]
; nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment