while (zae != null) { try { if (!zae.isDirectory() && zipArchiveInputStream.canReadEntryData(zae)) { outputStream.putArchiveEntry(zae);
ZipFile zipFile = new ZipFile("C:\\test.zip"); byte[] buf = new byte[65536]; Enumeration<?> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry zipArchiveEntry = (ZipArchiveEntry) entries.nextElement(); int n; InputStream is = zipFile.getInputStream(zipArchiveEntry); ZipArchiveInputStream zis = new ZipArchiveInputStream(is); if (zis.canReadEntryData(zipArchiveEntry)) { while ((n = is.read(buf)) != -1) { if (n > 0) { System.out.println(new String(buf)); } } } zis.close(); }
while ((entry = zipIn.getNextZipEntry()) != null) { if (file.matcher(entry.getName()).matches()) { if (zipIn.canReadEntryData(entry)) { long size = entry.getSize(); Files.write(zipIn, size, destination);
if (file.matcher(entry.getName()).matches()) { if (zipIn.canReadEntryData(entry)) {
/** * Find and add the entries located in the passed XAR file. * * @param xarStream an input stream to a XAR file * @throws IOException when failing to read the file * @throws XarException when failing to parse the XAR package */ public void read(InputStream xarStream) throws IOException, XarException { ZipArchiveInputStream zis = new ZipArchiveInputStream(xarStream, "UTF-8", false); try { for (ZipArchiveEntry entry = zis.getNextZipEntry(); entry != null; entry = zis.getNextZipEntry()) { if (!entry.isDirectory() && zis.canReadEntryData(entry)) { readEntry(zis, entry.getName()); } } } finally { zis.close(); } }