Estou com um problema para descompactar arquivos .zip que possuem subpastas.
Se eu coloco todos os arquivos na raiz do zip, o erro não acontece, mas se eu coloco algum dentro de alguma pasta ele não o encontra.
O erro apresentado é o seguinte:
java.io.FileNotFoundException: fotos\foto1.htm (O sistema não pode encontrar o caminho especificado)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:179)
at java.io.FileOutputStream.(FileOutputStream.java:70)
at servico.main.MainServico.main(MainServico.java:36)
e o codigo que eu escrevi é o seguinte:
public class Zip{
static final int BUFFER = 2048;
public static void main (String argv[]) {
try {
BufferedOutputStream dest = null;
BufferedInputStream is = null;
ZipEntry entry;
ZipFile zipfile = new ZipFile("c:\\zip\\arquivo.zip");
Enumeration e = zipfile.entries();
while(e.hasMoreElements()) {
entry = (ZipEntry) e.nextElement();
System.out.println("Extracting: " +entry);
is = new BufferedInputStream (zipfile.getInputStream(entry));
int count;
byte data[] = new byte[BUFFER];
FileOutputStream fos = new FileOutputStream(entry.getName());
dest = new BufferedOutputStream(fos, BUFFER);
while ((count = is.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
is.close();
}
} catch(Exception e) {
e.printStackTrace();
}
}
}