Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
cicovec-at-hotmail #1
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
-
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... -
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... -
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... -
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,... -
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... -
adonis1976 #2
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
-
cicovec-at-hotmail #3
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



Reply With Quote

