Download the two files at the same time using the following code:
ImportJava. Io. file;
ImportJava. Io. fileinputstream;
ImportJava. Io. fileoutputstream;
ImportJava.util.zip. zipentry;
ImportJava.util.zip. zipoutputstream;
Public
ClassZipoutputstreamdemo {
Public
Static
VoidMain (string [] ARGs)
ThrowsException {
Byte[] Buffer =
New
Byte[1024];
// The generated ZIP file name is demo.Zip
String strzipname =
"Demo.zip ";
Zipoutputstream out =
NewZipoutputstream (New
Fileoutputstream (strzipname ));
// Result of the two files to be downloaded at the same time.Txt
, Source.Txt
File [] file1 = {New
File ("result.txt "),New
File ("source.txt ")};
For(Int
I = 0; I <file1.length; I ++ ){
Fileinputstream FCM =
NewFileinputstream (file1 [I]);
Out. putnextentry (New
Zipentry (file1 [I]. getname ()));
IntLen;
// Read the content of the object to be downloaded and package itZipFile
While(LEN = FCM. Read (buffer)> 0 ){
Out. Write (buffer, 0, Len );
}
Out. closeentry ();
FCM. Close ();
}
Out. Close ();
System.Out. Println ("demo.zip created ");
}
} There is also the following reference: http://wjhcomputer.iteye.com/blog/1000333http://topic.csdn.net/u/20070209/09/ed602597-c693-4ec1-b9eb-51d35e493d10.htmlhttp://topic.csdn.net/u/20100727/14/6b86a6a8-5ee4-4d3b-ae5e-004eead66fde.html