on 03-30-2010 6:27 AM
Hi,
I am using ZIP API in Web Dynpro JAVA for multiple file download scenario.
Issue:--->
Some files are not opening correctly after unzipping the ZIP file.
Example-1: some PDF files gives out message that " "
Example-2: Also, a JPG file shows only upper half of the image.
So in all, the content of generated ZIP file are damaged.
Any idea why this is happening?
Thanks & regards,
Amey
It worked with readFully(byte[] b) method of DataInputStream.
Following code has to be used to read & fill up byte[] :-
DataInputStream l_dis = new DataInputStream(l_inputStream);
l_dis.readFully(l_byteArray);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And this is the code I'm using:-
Unzipped PDF files give this error --> There was an error opening this document. The file is damaged and could not be repaired
for(int i = 0; i < l_int_NodeSize; i++){
g_SearchOutputEle = g_SearchOutputNode.getCtx_vn_SearchOutputElementAt(i);
java.net.URL url = new URL(g_SearchOutputEle.getFileUrl());
java.net.URLConnection urlConnection = url.openConnection();
java.io.InputStream inputStream = url.openStream();
int arraySize = urlConnection.getContentLength();
byte[] byteArray = new byte[arraySize];
DataInputStream dis = new DataInputStream(inputStream);
dis.read(byteArray);
ZipEntry zipEntry = new ZipEntry("Name-"+i);
zipEntry.setSize(byteArray.length);
zos.putNextEntry(zipEntry);
zos.write(byteArray);
zos.closeEntry();
}
zos.close();
byte[] byteOutArray = baos.toByteArray();
IWDResource resource = WDResourceFactory.createResource(byteOutArray, "Downloads.zip",WDWebResourceType.UNKNOWN);
String urlString = resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());
IWDWindow win_MultiFileWindow = wdComponentAPI.getWindowManager().createNonModalExternalWindow(urlString);
win_MultiFileWindow.setWindowSize(0,0);
win_MultiFileWindow.show();
Edited by: Amey Mogare on Mar 30, 2010 7:49 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
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.