Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure:在类路径上找不到System/IO/File__init.class、System/IO/File.clj或System/IO/File.cljc_Clojure - Fatal编程技术网

Clojure:在类路径上找不到System/IO/File__init.class、System/IO/File.clj或System/IO/File.cljc

Clojure:在类路径上找不到System/IO/File__init.class、System/IO/File.clj或System/IO/File.cljc,clojure,Clojure,我正在尝试运行以下代码,将.csv文件(可以认为是纯文本)减少到100行: (ns tst.demo.core (:require [clojure.java.io :as io] [System.IO.File]) (:import [java.io File])) (defn lines [n filename] (with-open [rdr (io/reader filename)] (doall (take n (line-seq rdr))))) (defn

我正在尝试运行以下代码,将.csv文件(可以认为是纯文本)减少到100行:

(ns tst.demo.core
  (:require [clojure.java.io :as io] [System.IO.File])
  (:import [java.io File]))

(defn lines [n filename]
  (with-open [rdr (io/reader filename)]
    (doall (take n (line-seq rdr)))))

(defn spit-lines [^String filename a-seq]
  (->> a-seq
       (System.Linq.Enumerable/Cast (type-args System.String))
       (System.IO.File/WriteAllLines filename)))

(spit-lines(lines 100 "test_set_batch1.csv")))
无论何时运行此操作,都会出现以下错误:

Syntax error (FileNotFoundException) compiling at (RemoveAfterLine100.clj:1:1).
Could not locate System/IO/File__init.class, System/IO/File.clj or System/IO/File.cljc on classpath.

我不知道是什么导致了这个错误。我在:requires中添加了System.IO.File,所以我认为它应该可以工作。

正如@mange和@Alan Thompson所指出的,我的问题是我试图在CLR和JVM上运行脚本。

您是在CLR上使用Clojure,还是在JVM上使用Clojure<代码>[java.io文件]看起来像是JVM,但
[System.io.File]
看起来像是CLR。不能同时使用两者。
System.Linq.Enumerable
绝对是CLR:正如@mange所说,Clojure托管在JVM或CLR(或Javascript)上。一次对多个主机(即,您所在的主机)使用互操作是没有意义的。