The Java command lastmodified() does not work in clojure
•
Java
I tried to get the last modification time from the file in clojure by executing Java commands
My code is: (Java. Io. File. LastModified "/ home / lol / lolness. TXT")
My mistake is: Java lang.ClassNotFoundException:java. io. File. lastModified(NO_SOURCE_FILE:24)
(Java. Io. File. Separator) can work
Edited by: clojure version 1.2 0-master-snapshot openjdk 1.6 for Java 0
Solution
LastModified is Java io. A method of file object To access it in clojure, use the following syntax:
(.lastModified (java.io.File. "/home/lol/lolness.txt"))
Note that the namespace clojure contrib. java-utils(1.1)/ clojure. java. IO (bleeding edge) provides a function file to create Java io. File object is more convenient Because you are at the forefront, the following are useful to you:
(require '[clojure.java.io :as io]) (.lastModified (io/file "/home/lol/lolness.txt"))
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码