From: Robert J. B. <ru...@bb...> - 2003-12-04 22:26:28
|
But will usable bandwidth be twice as available... Ken Anderson wrote: >Here's some code for reading and writing data from a zipped file. >It assumes the zipped file has only one element, the file you want to read. >I though Geoffrey might like this, but Rusty would say "wait a year and space will be twice as cheap". >k > >(import "java.util.zip.ZipFile") >(import "java.util.zip.ZipOutputStream") >(import "java.util.zip.ZipEntry") > >;;; withZipWriter: String File (PrintWriter -> void) -> void >(define (withZipWriter name outputFile f) > ;; outputFile will be a zip file with one element in it, named name. > (let* ((out (ZipOutputStream. (FileOutputStream. outputFile))) > (w (PrintWriter. (BufferedWriter. (OutputStreamWriter. out))))) > (.putNextEntry out (ZipEntry. name)) > (f w) > (.flush w) > (.closeEntry out) > (.close out))) > >;;; withZipReader: ZipFile (BufferedReader -> Object) -> Object >(define (withZipReader zipFile f) > (let* ((zip (ZipFile. zipFile)) > (r (BufferedReader. > (InputStreamReader. > (.getInputStream zip (.nextElement (.entries zip)))))) > (result (f r))) > (.close r) > result)) > > > >------------------------------------------------------- >This SF.net email is sponsored by: IBM Linux Tutorials. >Become an expert in LINUX or just sharpen your skills. Sign up for IBM's >Free Linux Tutorials. Learn everything from the bash shell to sys admin. >Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user > > > > |