cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thelizardreborn <seth.f...@lat-inc.com>
Subject FileInputStream/GZIPOutputStream in flow
Date Mon, 21 Jul 2008 20:38:55 GMT

I am having a problem writing a gzip file from my flowscript. My basic goal
is to use flow to gzip existing html documents. The gzip file is being
created, but is empty (the source file is definitely not empty). Here is the
relevant part of the code I am using:

    try {
      var sep = java.io.File.separator;
      // Create the GZIP output stream
      var outFilename = "path"+sep+"to"+sep+"file"+sep+"filename.gzip";
//absolute file path
      var out = new java.util.zip.GZIPOutputStream(new
java.io.FileOutputStream(outFilename));

      // Open the input file
      var inFilename = "path"+sep+"to"+sep+"file"+sep+"filename.html";
//absolute file path
      java.lang.System.out.println(inFilename);
      var lineIn = new java.io.FileInputStream(inFilename);

      // Transfer bytes from the input file to the GZIP output stream
      /* --Original Code Sample: 
       * --(ByteArrayOutputStream used instead to get through the
javascript-ness of flowscript types)
       * var buf = new byte[1024];
       */
      var myByteArray = new java.io.ByteArrayOutputStream(1024);
      var buf = myByteArray.toByteArray();
      var len;
      while ((len = lineIn.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
      lineIn.close();

      // Complete the GZIP file
      out.finish();
      out.close();
    } catch (e) {
      java.lang.System.out.println(e);
    }

At this point, when I run the code, no errors appear in any of the logs. Any
ideas what I'm doing wrong? 
-- 
View this message in context: http://www.nabble.com/FileInputStream-GZIPOutputStream-in-flow-tp18577080p18577080.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message