Created
December 3, 2009 21:16
-
-
Save angerman/248532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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