java.util.zip.ZipOutputStream

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default java.util.zip.ZipOutputStream

    I'd like to create an object, which would save a created zipfile into a
    variable instead of file.

    OutputStream =
    createObject("java","java.io.FileOutputStream").in it("c:\a.zip");
    ZipStream =
    createObject("java","java.util.zip.ZipOutputStream ").init(OutputStream);

    This code works just perfect, but it creates a file (c:\a.zip) this is
    unwanted, I'd like to put this filecontents into a string variable.
    I'm newbie in Java, so after hours of trying everything from the java.io
    class, I decided to ask for help here.

    Thank you in advance.

    cicovec-at-hotmail Guest

  2. Similar Questions and Discussions

    1. SNMP::Util
      Hi There, Have been struggling whole afternoon on how to get SNMP::Util working. My (wrong??, hope so) conclusion is that it is not compatible...
    2. java.util.Arrays$ArrayList exception causing JRun error
      We have a website running on a dedicated ColdFusion MX 6.1/Windows 2003 web server that has been running without any problems for two months (since...
    3. How to cast cfquery object to type java.util.Map
      In the LiveDocs it says: "..The following table lists how ColdFusion converts ColdFusion data values to Java data types when passing arguments. The...
    4. List::Util / arrays
      On Aug 5, Jakob Kofoed said: Are those line numbers actually in the file too? If so, that might cause problems for you. At this point,...
    5. programatic CPU util
      I am looking for the way to programaticly determine CPU utilization under AIX (5L would be sufficient) to add to netperf. On linux netperf uses...
  3. #2

    Default Re: java.util.zip.ZipOutputStream

    need to see ur init() function in line 1 to figure out how you are using the argument passed in the method.
    adonis1976 Guest

  4. #3

    Default Re: java.util.zip.ZipOutputStream

    Ok, I finally figured how to make a zipOutputStream become the type I needed,
    It was ByteArray object (solution is in the code), but now I stand in front of
    another problem - How to send the zip output to the client on ColdFusion MX 6.1

    <cfheader name="Content-Disposition" value="attachment;
    filename=#filename#.zip">
    <cfcontent type="application/unknown" reset="yes"
    variable="#filecontents#"><cfabort>

    This code only works in MX 7, is there a way to send binary data to client in
    ColdFusion MX6.1?

    <cfscript>
    function createZipFile(variable) {
    jStringWriter = createObject("java","java.io.StringWriter").init() ;
    jByteArrayOutputStream =
    createObject("java","java.io.ByteArrayOutputStream ").init();
    jZipStream =
    createObject("java","java.util.zip.ZipOutputStream ").init(jByteArrayOutputStream
    );
    jZipStream.setLevel(0);
    streams.jZipStream = jZipStream;
    streams.jByteArrayOutputStream = jByteArrayOutputStream;
    return streams;
    }

    function addZipEntry(streams, entryname, contents) {
    var jZipEntry =
    createObject("java","java.util.zip.ZipEntry").init (entryname);
    var buffer = repeatString(" ", 1024).getBytes();
    var Data = "";
    var jInputStream =
    createObject("java","java.io.StringReader").init(c ontents);
    var jZipStream = streams.jZipStream;
    jZipStream.putNextEntry(jZipEntry);

    Data = jInputStream.read();
    if (Data neq -1) {
    do {
    jZipStream.write(Data);
    Data = jInputStream.read();
    } while(Data neq -1);
    }
    jZipStream.closeEntry();
    }

    function CloseZipStream(streams) {
    var ret = "";
    streams.jZipStream.close();
    ret = streams.jByteArrayOutputStream.toByteArray();
    streams.jByteArrayOutputStream.close();
    return ret;
    }
    </cfscript>

    cicovec-at-hotmail Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139