Answer the question
In order to leave comments, you need to log in
How to read from a zip archive?
Hello ! There are folders and files in my zip archive, only 1 file is read, how to count all files and folders?
PS - I am writing a launcher for minecraft :D
Here is my code.
public static void unZip(String arhiv, String outDir){
try {
ZipInputStream zis = new ZipInputStream(new FileInputStream(arhiv));
String name;
long size;
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null){
name = entry.getName();
size = entry.getSize();
System.out.println("Получены файлы: " + name + ", размером - " + size + " ; ");
FileOutputStream out = new FileOutputStream(outDir + name);
for (int c = zis.read(); c != -1; c++){
out.write(c);
}
out.flush();
zis.closeEntry();
out.close();
}
} catch (IOException e){
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
for (int c = zis.read(); c != -1; c++){
out.write(c);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question