Java Code Examples for org.apache.commons.compress.archivers.zip.ZipArchiveInputStream#getNextZipEntry()
The following examples show how to use
org.apache.commons.compress.archivers.zip.ZipArchiveInputStream#getNextZipEntry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUploadServlet.java From EasyML with Apache License 2.0 | 6 votes |
public static void unZipFiles(InputStream instream, String ID) throws IOException { ZipArchiveInputStream zin = new ZipArchiveInputStream(instream); java.util.zip.ZipEntry entry = null; while ((entry = zin.getNextZipEntry()) != null) { String zipEntryName = entry.getName(); String outPath = zipEntryName.replaceAll("\\*", "/"); String path = "lib"; path += zipEntryName.substring(zipEntryName.indexOf('/'), zipEntryName.length()); System.out.println("[path ]:" + path); if (!outPath.endsWith("/")) { InputStream in = zin; HDFSIO.uploadModel("/" + ID + "/" + path, in); } } zin.close(); }
Example 2
Source File: EntityImportExport.java From cuba with Apache License 2.0 | 6 votes |
@Override public Collection<Entity> importEntitiesFromZIP(byte[] zipBytes, EntityImportView view) { Collection<Entity> result = new ArrayList<>(); Collection<? extends Entity> entities; ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(zipBytes); ZipArchiveInputStream archiveReader = new ZipArchiveInputStream(byteArrayInputStream); try { try { while (archiveReader.getNextZipEntry() != null) { String json = new String(readBytesFromEntry(archiveReader), StandardCharsets.UTF_8); entities = entitySerialization.entitiesCollectionFromJson(json, null, EntitySerializationOption.COMPACT_REPEATED_ENTITIES); result.addAll(importEntities(entities, view)); } } catch (IOException e) { throw new RuntimeException("Exception occurred while importing report", e); } } finally { IOUtils.closeQuietly(archiveReader); } return result; }