IllegalArgumentException没有方法的实现:: make-reader of protocol:#’clojure.java.io / IOFactory for class:nil clojure.core / -cache-protocol-fn(core_deftype.clj:554)
我的研究表明,这通常意味着clojure正在寻找某些东西而无法找到它.但我无法弄清楚它可能是什么或为什么.
这是抛出异常的Clojure代码:
(ns org.stuff.events.data (:require [clojure.java.io :as io]))(def data-file (io/file (io/resource "kamus.csv")))(defn read-data [_] (slurp data-file))
从最好的我可以告诉“kamus.csv”在正确的目录中,所以我不认为这是它.如果我在repl中评估数据文件,我会得到nil.
有人有任何想法来解决我的问题吗?
以下是其他项目文件仅供参考:
main.clj:
(ns org.stuff.events.main (:require [neko.activity :refer [defactivity set-content-vIEw!]] [neko.deBUG :refer [*a]] [neko.notify :refer [toast]] [neko.ui :refer [config]] [neko.resource :as res] [neko.find-vIEw :refer [find-vIEw]] [neko.threading :refer [on-ui]] [org.stuff.events.data :as data] [clojure.data.csv :as csv]) (:import androID.Widget.TextVIEw));; We execute this function to import all subclasses of R class. This gives us;; access to all application resources.(res/import-all)(def Listing (atom ""))(defn get-elem [activity ID] (str (.getText (find-vIEw activity ID))))(defn set-elem [activity ID s] (on-ui (config (find-vIEw activity ID) :text s)))(defn add-event [activity] (swap! Listing str (get-elem activity ::search-Box) "\n") (set-elem activity ::results @Listing))(defn main-layout [activity] [:linear-layout {:orIEntation :vertical} [:linear-layout {:orIEntation :horizontal :layout-height :wrap} [:edit-text {:ID ::search-Box :hint "cari..." :layout-wIDth :fill}] [:button {:text "Cari" :on-click (fn [_] (add-event (*a)))}]] [:text-vIEw {:text @Listing :ID ::results}]]);; This is how an Activity is defined. We create one and specify its onCreate;; method. InsIDe we create a user interface that consists of an edit and a;; button. We also give set callback to the button.(defactivity org.stuff.events.MainActivity :key :main (onCreate [this bundle] (.superOnCreate this bundle) (neko.deBUG/keep-screen-on this) (on-ui (set-content-vIEw! (*a) (main-layout (*a))))))
project.csj:
(defproject events/events "0.1.0-SNAPSHOT" :description "FIXME: AndroID project description" :url "http://example.com/FIXME" :license {:name "Eclipse Public license" :url "http://www.eclipse.org/legal/epl-v10.HTML"} :global-vars {*warn-on-reflection* true} :source-paths ["src/clojure" "src"] :res-path "src/main/resources" :java-source-paths ["src/java"] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :plugins [[lein-droID "0.4.3"]] :dependencIEs [[org.clojure-androID/clojure "1.7.0-r2"] [neko/neko "4.0.0-Alpha5"] [org.clojure/data.csv "0.1.3"] ] :profiles {:default [:dev] :dev [:androID-common :androID-user {:dependencIEs [[org.clojure/tools.nrepl "0.2.10"]] :target-path "target/deBUG" :androID {:aot :all-with-unused :rename-manifest-package "org.stuff.events.deBUG" :manifest-options {:app-name "EventsListing (deBUG)"}}}] :release [:androID-common {:target-path "target/release" :androID {;; :keystore-path "/home/user/.androID/private.keystore" ;; :key-alias "mykeyalias" ;; :sigalg "MD5withRSA" :ignore-log-priority [:deBUG :verbose] :aot :all :build-type :release}}]} :androID {;; Specify the path to the AndroID SDK directory. :sdk-path "C:\Users\fhard\AppData\Local\AndroID\sdk" ;; Try increasing this value if dexer fails with ;; OutOfMemoryException. Set the value according to your ;; available RAM. :dex-opts ["-JXmx4096M" "--incremental"] :target-version "15" :aot-exclude-ns ["clojure.parallel" "clojure.core.reducers" "cider.nrepl" "cider-nrepl.plugin" "cider.nrepl.mIDdleware.util.java.parser" #"clJs-tooling\..+"]})解决方法 从例外情况来看,根据 this answer看起来你的路径错了.当我尝试用io / resource打开一个文件时,即使文件实际存在,我也会得到同样的错误. io/reader可能更容易使用,因为它会将您的输入强制转换为读者对象.另一方面,io / resource返回一个URL,其路径在jar内部发生变化. Check this. 总结
以上是内存溢出为你收集整理的Clojure android无法读取文件全部内容,希望文章能够帮你解决Clojure android无法读取文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)