I am working on a project that requires me to get the size of a file and
access it's last date of modification. It seems like the java methods
.length and .lastmodified could be pretty handy in this situation. I am,
however, having a bit of trouble wrapping my head around how to access a
java method from a clojure project. Some examples I have seen import the
java classes directly, as you would in a standard java project, whereas
others seem to take a different approach. I decided to import java.io.File
and try to get the length of a file:
(defn get-length [file]
(println (.length file)))) <---a rather crude representation of
my effort.
When I ran this, no exceptions were thrown and it gave me a length, only
that length was the number of words in the file name I provided, not the
actual size of the file. It seems as though clojure may have a different
length function built-in, but I'm not sure. So to get to the overall point:
what is the standard way to access java methods from clojure (if there is
one)? Do I simply need to import the java class, or is there much more to
it that I am not yet understanding?
Any tips would be great. I am new and loving the language, but a bit
confused. Thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.