I
Ike
I am looking to enumerate all of the file names in a zip file.
If I have a zip file, abc.zip, and it is local, at the root of my classpath,
I can call the following method with :
ArrayList arrayList = new ArrayList();
getAllFiles(arrayList, "/" + "abc.zip);
with an applet, running in appletviewer on the local machine, and the files
within the zip file are enumerated correctly.
However, when I move the applet to a website, (this is a signed applet btw),
and put abc.zip on the website as well, (thus they both reside in the
website specified as CLASSPATH within the html page that calls the applet),
it completely blows up on me (at the line f = new ZipFile(zipFileName)
with the error message "ava.util.zip.ZipException: The system cannot find
the file specified"
Can someone please tell me how I can call this correctly when I have the zip
file on the web in the classpath? Thank you. -Ike
public void getAllFiles(ArrayList s,URL zipFileURL){
getAllFiles(s, zipFileURL.getFile());
}
public void getAllFiles(ArrayList s, String zipFileName){
ZipFile f=null;
try {
f = new ZipFile(zipFileName);
Enumeration e = f.entries();
while (e.hasMoreElements()){
ZipEntry entry = (ZipEntry) e.nextElement();
s.add(entry.getName());
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
try{
f.close();
}catch(Exception ex2){
ex2.printStackTrace();
}
}
}
If I have a zip file, abc.zip, and it is local, at the root of my classpath,
I can call the following method with :
ArrayList arrayList = new ArrayList();
getAllFiles(arrayList, "/" + "abc.zip);
with an applet, running in appletviewer on the local machine, and the files
within the zip file are enumerated correctly.
However, when I move the applet to a website, (this is a signed applet btw),
and put abc.zip on the website as well, (thus they both reside in the
website specified as CLASSPATH within the html page that calls the applet),
it completely blows up on me (at the line f = new ZipFile(zipFileName)
with the error message "ava.util.zip.ZipException: The system cannot find
the file specified"
Can someone please tell me how I can call this correctly when I have the zip
file on the web in the classpath? Thank you. -Ike
public void getAllFiles(ArrayList s,URL zipFileURL){
getAllFiles(s, zipFileURL.getFile());
}
public void getAllFiles(ArrayList s, String zipFileName){
ZipFile f=null;
try {
f = new ZipFile(zipFileName);
Enumeration e = f.entries();
while (e.hasMoreElements()){
ZipEntry entry = (ZipEntry) e.nextElement();
s.add(entry.getName());
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
try{
f.close();
}catch(Exception ex2){
ex2.printStackTrace();
}
}
}