Tuesday, March 16, 2010

List files in a directory

; import the java.io.File class
(import java.io.File)

; get a list of files in the current directory - recursively, including subdirectories
(file-seq (File. "."))
(# # # # # # # # # # ... rest of the files ...)

; for each file in the current directory, print the file object
(doseq [file (file-seq (File. "."))] (println file))
... list of File objects ...
#
#
#
#
#
... rest of the files ...

(doseq [file (file-seq (File. "."))] (println (. file getName)))
... list of file names ...
Seqable.java
SeqEnumeration.java
SeqIterator.java
Sequential.java
Settable.java
... rest of the files ...

No comments:

Post a Comment