3

Code in clojure:

(import '(java.nio.file Files))
(Files/createTempDirectory "Test")

There is error:

CompilerException java.lang.IllegalArgumentException: No matching method: createTempDirectory, compiling:xxxx

But in java's doc http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempDirectory(java.lang.String,%20java.nio.file.attribute.FileAttribute...)

There is an String parameter for createTempDirectory, I'm using java 1.7.0

Shawn Zhang
  • 1,680
  • 1
  • 12
  • 21
  • 1
    when calling java method with variable arguments from clojure, you cannot omit the variable argument. you have to give array of `FileAttribute` as second argument, see http://stackoverflow.com/questions/11702184/how-to-handle-java-variable-length-arguments-in-clojure. – ymonad Nov 05 '14 at 02:54

1 Answers1

7

Try this code:

(java.nio.file.Files/createTempDirectory "Test"
  (into-array java.nio.file.attribute.FileAttribute []))

As @ymonad mentioned, you cannot omit the variable argument when calling java method with variable arguments. If you don't want to specify the FileAttribute, just pass the empty array of the type.

ntalbs
  • 28,700
  • 8
  • 66
  • 83