/
GermanezZ
/
JavaExercises
Обзор
Документация
Войти
/
GermanezZ
/
JavaExercises
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
AllMetanitLessons/FilesWorkingWith/Zip/ZipInputProg.java
42 строки
1 KB
germa
Уроки по Metanit
04 дек 2024, 20:39
04 дек 2024, 20:39
48d575a
Код
Авторство
О чём код?
package AllMetanitLessons.FilesWorkingWith.Zip; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class ZipInputProg { public static void main(String[] args) { try(ZipInputStream zis = new ZipInputStream(new FileInputStream("D://Files//output.zip"))) { ZipEntry entry; String name; long size; while ((entry = zis.getNextEntry())!= null){ name = entry.getName(); byte[] arr = zis.readAllBytes(); size = arr.length; System.out.printf("Name: %s, sise: %d\n",name,size); FileOutputStream fis = new FileOutputStream("D://Files//new" + name); fis.write(arr); fis.flush(); zis.closeEntry(); fis.close(); } }catch (IOException exc){ System.out.println(exc.getMessage()); } } }