-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2
-
x86
-
windows_xp
FULL PRODUCT VERSION :
1.4.2_04
ADDITIONAL OS VERSION INFORMATION :
windows XP SP2 build 2600 version 5.1
A DESCRIPTION OF THE PROBLEM :
If I create a ZipFile Object on a File that was made with winzip and the winzip archiv *.zip had no entrys an ZipException is happend.
If the file contains Entry(s) there is no Exception
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new File of type winzip without any entrys
use the programm to list the contents
on this line of code it happens a ZipException f = new ZipFile(ff);
/** Liest alle dir Entrys in ArrayList
*
* @param archiv String
* @return ArrayList
*/
private ArrayList getDirEntrys(String archiv)
{
ArrayList al = new ArrayList();
ZipFile f = null;
try
{
File ff = new File(archiv);
f = new ZipFile(ff);
Enumeration enum = f.entries();
while (enum.hasMoreElements())
{
ZipEntry entry = (ZipEntry) enum.nextElement();
if (entry.isDirectory())
{
al.add(entry.getName());
}
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
try
{
if (f != null)
{
f.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
System.out.println("Found " + al.size() + " Dir entrys");
return al;
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no Exception
ACTUAL -
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class ziptest
{
public static void main(String[] args)
{
new ziptest().getDirEntrys("test.zip");
}
private ArrayList getDirEntrys(String archiv)
{
ArrayList al = new ArrayList();
ZipFile f = null;
try
{
File ff = new File(archiv);
f = new ZipFile(ff);
Enumeration enum1 = f.entries();
while (enum1.hasMoreElements())
{
ZipEntry entry = (ZipEntry) enum1.nextElement();
if (entry.isDirectory())
{
al.add(entry.getName());
}
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
try
{
if (f != null)
{
f.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
System.out.println("Found " + al.size() + " Dir entrys");
return al;
}
}
---------- END SOURCE ----------
1.4.2_04
ADDITIONAL OS VERSION INFORMATION :
windows XP SP2 build 2600 version 5.1
A DESCRIPTION OF THE PROBLEM :
If I create a ZipFile Object on a File that was made with winzip and the winzip archiv *.zip had no entrys an ZipException is happend.
If the file contains Entry(s) there is no Exception
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new File of type winzip without any entrys
use the programm to list the contents
on this line of code it happens a ZipException f = new ZipFile(ff);
/** Liest alle dir Entrys in ArrayList
*
* @param archiv String
* @return ArrayList
*/
private ArrayList getDirEntrys(String archiv)
{
ArrayList al = new ArrayList();
ZipFile f = null;
try
{
File ff = new File(archiv);
f = new ZipFile(ff);
Enumeration enum = f.entries();
while (enum.hasMoreElements())
{
ZipEntry entry = (ZipEntry) enum.nextElement();
if (entry.isDirectory())
{
al.add(entry.getName());
}
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
try
{
if (f != null)
{
f.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
System.out.println("Found " + al.size() + " Dir entrys");
return al;
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no Exception
ACTUAL -
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class ziptest
{
public static void main(String[] args)
{
new ziptest().getDirEntrys("test.zip");
}
private ArrayList getDirEntrys(String archiv)
{
ArrayList al = new ArrayList();
ZipFile f = null;
try
{
File ff = new File(archiv);
f = new ZipFile(ff);
Enumeration enum1 = f.entries();
while (enum1.hasMoreElements())
{
ZipEntry entry = (ZipEntry) enum1.nextElement();
if (entry.isDirectory())
{
al.add(entry.getName());
}
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
try
{
if (f != null)
{
f.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
System.out.println("Found " + al.size() + " Dir entrys");
return al;
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-4971117 ZipException thrown when empty jar file in classpath
-
- Closed
-
- relates to
-
JDK-6440786 Cannot create a ZIP file containing zero entries
-
- Closed
-