-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
sparc
-
solaris_8
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS braw061 5.8 Generic_117350-28 sun4u sparc SUNW,Sun-Blade-1500
A DESCRIPTION OF THE PROBLEM :
We have a file which needs to be unzip using java.util.zip.ZipFile.
It was created a class which would unzip it but when executing new ZipFile("myzip.zip) an exception is received :
Exception in thread "main" java.util.zip.ZipException: invalid CEN header (bad compression method)
If I try to decompress the same file using "unzip" or "winzip" no errors occour but when using "jar" it also fails giving the following message:
java.util.zip.ZipException: invalid CEN header (bad compression method)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:203)
at java.util.jar.JarFile.<init>(JarFile.java:132)
at java.util.jar.JarFile.<init>(JarFile.java:70)
at sun.tools.jar.Main.getJarPath(Main.java:793)
at sun.tools.jar.Main.genIndex(Main.java:827)
at sun.tools.jar.Main.run(Main.java:195)
at sun.tools.jar.Main.main(Main.java:903)
It seems that this bug is connected to bug 4419591.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 - First you will need to have my specific zip file which I can send you by mail
2- Run the code I've provided here.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.util.zip.ZipException: invalid CEN header (bad compression method)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class UnZip{
public static ZipFile zf;
public static final int EOF = -1;
public static void main( String argv[] ) throws IOException {
Enumeration e;
try {
zf = new ZipFile( "myzip.zip" );
e = zf.entries();
while( e.hasMoreElements() ) {
ZipEntry target = (ZipEntry)e.nextElement();
System.out.print( target.getName() + " ." );
saveEntry( target );
System.out.println( ". unpacked" );
}
}
catch( FileNotFoundException exc ){
System.out.println( "zipfile not found" );
}
}
public static void saveEntry( ZipEntry target )
throws ZipException,IOException {
try {
File file = new File( target.getName() );
if( target.isDirectory() ) {
file.mkdirs();
}
else {
InputStream is = zf.getInputStream( target );
BufferedInputStream bis = new BufferedInputStream( is );
if ( file.getParent() != null){
File dir;
dir = new File( file.getParent() );
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream( file );
BufferedOutputStream bos = new BufferedOutputStream( fos );
int c;
while( ( c = bis.read() ) != EOF ) {
bos.write( (byte)c );
}
bos.close();
fos.close();
}
}
catch( ZipException e ){
throw e;
}
catch( IOException e ){
throw e;
}
}
}
---------- END SOURCE ----------
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS braw061 5.8 Generic_117350-28 sun4u sparc SUNW,Sun-Blade-1500
A DESCRIPTION OF THE PROBLEM :
We have a file which needs to be unzip using java.util.zip.ZipFile.
It was created a class which would unzip it but when executing new ZipFile("myzip.zip) an exception is received :
Exception in thread "main" java.util.zip.ZipException: invalid CEN header (bad compression method)
If I try to decompress the same file using "unzip" or "winzip" no errors occour but when using "jar" it also fails giving the following message:
java.util.zip.ZipException: invalid CEN header (bad compression method)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:203)
at java.util.jar.JarFile.<init>(JarFile.java:132)
at java.util.jar.JarFile.<init>(JarFile.java:70)
at sun.tools.jar.Main.getJarPath(Main.java:793)
at sun.tools.jar.Main.genIndex(Main.java:827)
at sun.tools.jar.Main.run(Main.java:195)
at sun.tools.jar.Main.main(Main.java:903)
It seems that this bug is connected to bug 4419591.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 - First you will need to have my specific zip file which I can send you by mail
2- Run the code I've provided here.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.util.zip.ZipException: invalid CEN header (bad compression method)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class UnZip{
public static ZipFile zf;
public static final int EOF = -1;
public static void main( String argv[] ) throws IOException {
Enumeration e;
try {
zf = new ZipFile( "myzip.zip" );
e = zf.entries();
while( e.hasMoreElements() ) {
ZipEntry target = (ZipEntry)e.nextElement();
System.out.print( target.getName() + " ." );
saveEntry( target );
System.out.println( ". unpacked" );
}
}
catch( FileNotFoundException exc ){
System.out.println( "zipfile not found" );
}
}
public static void saveEntry( ZipEntry target )
throws ZipException,IOException {
try {
File file = new File( target.getName() );
if( target.isDirectory() ) {
file.mkdirs();
}
else {
InputStream is = zf.getInputStream( target );
BufferedInputStream bis = new BufferedInputStream( is );
if ( file.getParent() != null){
File dir;
dir = new File( file.getParent() );
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream( file );
BufferedOutputStream bos = new BufferedOutputStream( fos );
int c;
while( ( c = bis.read() ) != EOF ) {
bos.write( (byte)c );
}
bos.close();
fos.close();
}
}
catch( ZipException e ){
throw e;
}
catch( IOException e ){
throw e;
}
}
}
---------- END SOURCE ----------