Reputation: 1767
I am getting this error:
java.util.zip.ZipException: invalid CEN header (bad signature)
and I am not quite sure what is the problem, when I search google for CEN
header nothing useful is found.
Any help is appreciated, thanks.
Here is the code and it fails on the last line:
ZipFile resourceZip = null;
if (pir.getSource().endsWith("Resources.zip"))
{
File temp = new File( "C:\\Users\\nbonnet\\Desktop\\new\\Resources1.zip");
byte[] bytesFromClob = ClobHelper.bytesFromClob(pir.getContents(),"latin1");
FileOutputStream out = new FileOutputStream(temp);
out.write(bytesFromClob);
out.flush();
out.close();
resourceZip = new ZipFile(temp); // <-- Code fails here
}
Upvotes: 0
Views: 6210
Reputation: 23265
You're writing the file as a regular (non-ZIP) file and then trying to read it back as a ZIP file. That's not going to work. You need to write it with a ZipOutputStream
.
Check out this example or this one.
Upvotes: 4