Advertisement
Guest User

Untitled

a guest
Sep 12th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (import (java.io BufferedReader FileReader))
  2.  
  3. (defn get-line
  4.   [file-name line]
  5.   (let [r (BufferedReader. (FileReader. file-name)) eof (Object.)]
  6.     (nth (take-while #(not= eof %) (repeatedly #(read r false eof))) line))
  7.  
  8. ; I want this function to take in a filen name and a line number and output the text in the file at that line.
  9.  
  10. ; It has to be on Clojure 1.1.0 right now.
  11.  
  12. ; Here's the error I am getting when I run it
  13.  
  14. ;ClassCastException java.io.BufferedReader cannot be cast to java.io.PushbackReader clojure.core/read (core.clj:3346)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement