Clojure中的代码:
(import '(java.nio.file Files))
(Files/createTempDirectory "Test")
Run Code Online (Sandbox Code Playgroud)
有错误:
CompilerException java.lang.IllegalArgumentException: No matching method: createTempDirectory, compiling:xxxx
Run Code Online (Sandbox Code Playgroud)
有一个String参数createTempDirectory,我正在使用Java 1.7.0
试试这个代码:
(java.nio.file.Files/createTempDirectory "Test"
(into-array java.nio.file.attribute.FileAttribute []))
Run Code Online (Sandbox Code Playgroud)
如@ymonad所述,在调用带有可变参数的java方法时不能忽略可变参数。如果您不想指定FileAttribute,则只需传递该类型的空数组即可。