I need to pin data coming from one stream and put the data in zip to another. Here is the code that works with files ( MyOutputStream- a simple FileOutputStream wrapper used for debugging). This code works great.
ZipOutputStream jos = new ZipOutputStream( new MyOutputStream(new FileOutputStream(zipFileName)));
jos.setLevel(Deflater.DEFAULT_COMPRESSION);
jos.putNextEntry(new ZipEntry("test.txt"));
FileInputStream in = new FileInputStream("test.txt");
int len;
while ((len = in.read(buffer)) > 0){
jos.write(buffer, 0, len);
}
jos.closeEntry();
jos.close();
In my real application, I have to deal with more complex threads. In fact, threads are used for CORBA interaction. However, the data is successfully read. But when I try to do jos.write(buffer, 0, len);, no data is written to the output stream underlying the ZipOutputStream. However, the zip file headers, comment entries, and the central directory are recorded successfully, so I get an absolutely reliable zip with the only exception that the files are empty.
, - ? .
, :
String fileName = fullSourcePath.substring(fullSourcePath.lastIndexOf('\\') + 1, fullSourcePath.length());
WrapperOutputStream out = new WrapperOutputStream(newexchangeStream64);
ZipOutputStream jos = new ZipOutputStream(out);
jos.setLevel(Deflater.NO_COMPRESSION);
jos.putNextEntry(new ZipEntry(fileName));
jos.setComment("Comment");
IDLDataHolder data = new IDLDataHolder();
LongHolder dataAmount = new LongHolder();
LongHolder written = new LongHolder();
while (true) {
exchangeStream64.Read(data, READ_AMOUNT, dataAmount);
if (0 == dataAmount.value) {
break;
}
jos.write(data.value, (int)dataAmount.value, (int)written.value);
}
jos.closeEntry();
jos.close();