Hi thelizardreborn,

I have migrated away from flowscript to javaflow partially because of the same issues with the javascript-ness of the types. But the following snippet seemed to do the trick for what you are attempting. I think your initial code would work if you also actually wrote 1024 bytes to your ByteArrayOutputStream as well as defining the buffer size.

var buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024);
var count = is.read(buffer);
var tot = 0;
while (count != -1) {
    tot += count;
    os.write(buffer, 0, count);
    count = is.read(buffer);
}
os.close();

Hope this helps.

Grtz, Suzan.
--
thelizardreborn schreef:
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?


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to