Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem in creating zip file on weblogic server

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i run following code on a tomcat server on local machine it rus fine & gives a correct zip file but when I run this on weblogic server then it gives error as

error:[c:\Documents & settings\mt1\local settings\temporary internet files\myzipfile[1].zip]": start of central directory not found. Zip file corrupt.
Possible error: Zip file error


Can anybody please help me in this?



 
Marshal
Posts: 22441
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That will probably already solve your problem. When read(byte[]) returns 0 that doesn't mean all data is read. It means there's currently no data available. -1 is the only value that indicates that you're done reading.

Also, you can remove this line:
reader.read(buffer) will re-fill the existing array. It's possible (likely even) that one or more reads do not overwrite all old data, but you know that all values from 0 to bytesRead (exclusive) are filled with new data, and this is exactly the portion you then write. In other words, all you're doing is create another array where no new array is necessary.
 
Tushar Mundada
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did above changes. its still not working. It seems there is problem with the header of the zip file. Can anybody help to resolve exactly?
 
Rob Spoor
Marshal
Posts: 22441
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this is a JSP, make sure that absolutely no output is sent to the response before you use your code. That includes line breaks outside of JSP directives / tags. Even enters between your import directives will already be sent to the response.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic