Hello,
I am trying to translate the following Java
snippet into a file copy routine in Clojure.
public static void copy(InputStream in, OutputStream out) throws
IOException {
byte[] buffer = new byte[1024];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) break;
out.write(buffer, 0, bytesRead);
}
}
I was barely able to start:
(defn copy [iname oname]
(let [in (new FileInputStream iname)
out (new FileOutputStream oname)]
nil))
But now I am totally lost at the "nil". I am not sure how to translate
the "while" loop.
I would appreciate any pointers on how to do this (or maybe a more
ideomatic
way).
Thanks.
Parth
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---