on 08-31-2007 3:08 PM
Hi,
i want to extract a zip archive within the Repository Framework. I can open and extract/write the first entry, but after that i get an exception which states that the (ZipInput)Stream is already closed.
I suspect the<b> updateContent </b>Method to do that. Is there any way around that autoclosing behavior? Or is there a total different approach to extract archives within the KM?
Many thanks for any hint.
Best regards
Jochen
P.S. i use a Wrapper for the Repository Framework, therefore i didn't yet post any code. But if it helps, i certainly will post it here.
Hi Jochen,
I don't understand your question completely - you have a ZIP resource and want to extract that, i.e. create several new resources?! In that case, "updateContent" won't be called on the ZIP resource?!
Please give some more details about your scenario, maybe a small portion of the code.
Best regards
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ZipInputStream zipIn = new ZipInputStream(zipResource.getContent().getInputStream());
ZipEntry entry = null;
while((entry =zipIn.getNextEntry())!=null)
{
resource = createResource(entry.getName()); //custom method
Content content = new Content(zipIn, mimeType, entry.getSize());
resource.updateContent(content);
}
}
The problem occurs after the first ZipEntry is extracted and written (i also can open the file within the KM UI). But after the first updateContent I than get a "Stream already closed"-Exception!
thank you very much for your help!
best regards
Jochen
P.S. basically i just want to extract a zip resource and create a new resource for each entry.
Hi Jochen,
I expect the Content constructor to close the passes InputStream.
To circumvent this, I would suggest to "manually" read in the zip input stream into some bytearray and then to create a ByteArrayInputStream and to pass this to the Content constructor. So the RF doesn't have the possibility to touch the ZIP things...
Besides: You are using the Java standard ZIP functionality - this has a bug for many years now, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499 (and the duplicate http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4415733 which has been posted by myself in 2001... oh, how long ago...)
Hope it helps
Detlev
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.