Sorry Gavin, didn't test the code. Should be pointed out that this will
work for only text files (not binary files) within a zip file and also the
character encodings might play up on some platforms, even so it could be a
very useful tool.

> Hi Rod,
>
> Thanks a lot for this.
>
> There was a slight bug whereby the first character of every line was
> missing because
>
>    while(BufInStream.read() neq -1) {
>
> read a character and it didn't read again in the readline command.
>
> Also the carriage returns we missing.
>
> Mark Lynch was kind enough to help me fix it, and i've pasted in the
> code below for anyone who needs something similar in the future.
>
> Cheers
>
> Gavin
>
> <cfscript>
> zipFilePath = application.defaultFilePath & "/" & file.serverFile;
> zipFile = createObject("java", "java.util.zip.ZipFile");
> InputStream = createObject("java", "java.io.InputStreamReader");
> BufInStream = createObject("java", "java.io.BufferedReader");
> xmlcontent = "";
> //open zipFile
> zipFile.init(zipFilePath);
> entries = zipFile.entries();
> while(entries.hasMoreElements()) {
>       entry = entries.nextElement();
>       if(NOT entry.isDirectory()) {
>               nm = entry.getName();
>               lenPth = len(nm) - len(getFileFromPath(nm));
>               if(nm eq "content.xml") {
>                       // read in text file
>                       
> BufInStream.init(InputStream.init(zipFile.getInputStream(entry)));
>                       thisLine = BufInStream.readLine();
>                       while(isDefined('thisLine')) {
>                               xmlcontent = xmlcontent & thisLine & chr(13)& 
> chr(10);
>                               thisLine = BufInStream.readLine();
>                       }
>               }
>       }
> }
>
>
> zipFile.close();
> </cfscript>
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
> [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
>


---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to