public TrueZipZipFileHandle( final File targetFile ) throws IOException { super( targetFile ); this.zipFile = new ZipFile( targetFile ); }
public void close() throws IOException { getZipFile().close(); }
public InputStream getEntryContent( String path ) throws IOException { ZipEntry entry = getZipFile().getEntry( path ); if ( entry != null ) { return getZipFile().getInputStream( entry ); } else { return null; } }
ZipFile zip = new ZipFile(source); for (Enumeration<? extends ZipEntry> it = zip.entries(); it .hasMoreElements();) { ZipEntry e = it.nextElement(); for (Enumeration<? extends ZipEntry> it = zip.entries(); it .hasMoreElements();) { ZipEntry entry = it.nextElement(); .getInputStream(entry)); zip.close();
@Override public void process(IdentificationRequest request, ContainerSignatureMatchCollection matches) throws IOException { ZipFile zipFile = new ZipFile(new TrueZipReader(request.getWindowReader()), ZipFile.DEFAULT_CHARSET, true, false); try { final ZipEntry entry = zipFile.getEntry(entryName); if (entry != null) { InputStream stream = zipFile.getInputStream(entry); ByteReader reader = null; try { zipFile.close();
assertEquals(ZIP_SIZE, buffer.getSize(Size.STORAGE)); final ZipFile zf = new ZipFile( buffer.getInputSocket().newReadOnlyFile()); try { final byte[] buf = new byte[data.length]; for ( final Enumeration<? extends ZipEntry> e = zf.entries(); e.hasMoreElements(); ) { final ZipEntry entry = e.nextElement(); final InputStream in = zf.getCheckedInputStream(entry); try { int off = 0; zf.close();
assertEquals(30, zipIn.size()); try { for (int i = 0; i < 30; i++) { final String name = i + ".txt"; final ZipEntry entry = zipIn.getEntry(name); assertEquals(data1.length, entry.getSize()); final InputStream in = zipIn.getInputStream(name); try { int off = 0; zipIn.close();
@Override protected ZipFile newZipFile(String name) throws IOException { ZipFile res = new ZipFile(name); res.setCryptoParameters(new WinZipAesCryptoParameters()); return res; }
/** * {@inheritDoc} */ @Override public void handle(IdentificationRequest request) throws IOException { final ZipFile zipFile = new ZipFile(new ReaderReadOnlyFile(request.getWindowReader())); try { Iterable<ZipEntry> iterable = new Iterable<ZipEntry>() { @Override public final Iterator<ZipEntry> iterator() { return new ZipFileIterator(zipFile); } }; ZipArchiveWalker walker = new ZipArchiveWalker(request.getIdentifier(), zipFile); walker.walk(iterable); } finally { if (zipFile != null) { zipFile.close(); } } }
final ZipFile zipIn = new ZipFile(file); // NOT newZipFile(...) ! InputStream in = zipIn.getCheckedInputStream(name); if (tweakDD ^ tweakCFH) fail("Expected CRC32Exception!"); InputStream in = zipIn.getCheckedInputStream(name); if (tweakDD ^ tweakCFH) fail("Expected CRC32Exception!"); zipIn.close();
@Test public final void testGetInputStream() throws IOException { final ZipOutputStream zipOut = newZipOutputStream(new FileOutputStream(file)); try { zipOut.putNextEntry(newEntry("foo")); } finally { zipOut.close(); } final ZipFile zipIn = newZipFile(file); try { zipIn.getInputStream("foo").close(); assertNull(zipIn.getInputStream("bar")); } finally { zipIn.close(); } }
@Test public final void testPreambleOfEmptyZipFile() throws IOException { // Create empty ZIP file. newZipOutputStream(new FileOutputStream(file)).close(); // Assert that the empty ZIP file has no preamble. final ZipFile zipIn = newZipFile(file); try { assertEquals(0, zipIn.getPreambleLength()); final InputStream in = zipIn.getPreambleInputStream(); try { assertEquals(-1, in.read()); } finally { in.close(); } } finally { zipIn.close(); } }
public ZipFileIterator(ZipFile fileToIterate) { entries = fileToIterate.entries(); }
@Test public final void testGoodGetCheckedInputStream() throws IOException { // Create test ZIP file. final String name = "entry"; final ZipOutputStream zipOut = newZipOutputStream(new FileOutputStream(file)); zipOut.putNextEntry(newEntry(name)); zipOut.write(data); zipOut.close(); final ZipFile zipIn = newZipFile(file); // Open checked input stream and join immediately. InputStream in = zipIn.getCheckedInputStream(name); in.close(); // Open checked input stream and read fully, using multiple methods. in = zipIn.getCheckedInputStream(name); final int n = data.length / 4; in.skip(n); in.read(new byte[n]); in.read(new byte[n], 0, n); while (in.read() != -1) { // read until EOF } in.close(); zipIn.close(); }
InputStream in = null; try { in = file.getInputStream(entry); request.open(in); } finally {
public boolean hasEntry( String path ) throws IOException { return getZipFile().getEntry( path ) != null; }
final ZipFile zip = new ZipFile(source.toFile()); for (final Enumeration<? extends ZipEntry> it = zip.entries(); it .hasMoreElements();) { ZipEntry e = it.nextElement(); for (final Enumeration<? extends ZipEntry> it = zip.entries(); it .hasMoreElements();) { ZipEntry entry = it.nextElement(); try (final InputStream in = new BufferedInputStream(zip.getInputStream(entry)); final OutputStream out = new BufferedOutputStream(Files.newOutputStream(expandedFile))) { bytesSoFar = readFile(in, out, observer, bytesSoFar, totalSize); zip.close();
@Override public void process(IdentificationRequest request, ContainerSignatureMatchCollection matches) throws IOException { ZipFile zipFile = new ZipFile(new ReaderReadOnlyFile(request.getWindowReader()), ZipFile.DEFAULT_CHARSET, true, false); try { final ZipEntry entry = zipFile.getEntry(entryName); if (entry != null) { InputStream stream = zipFile.getInputStream(entry); ByteReader reader = null; try { zipFile.close();
@Override protected ZipFile newZipFile( File file, Charset charset) throws IOException { ZipFile res = new ZipFile(file, charset); res.setCryptoParameters(new WinZipAesCryptoParameters()); return res; }
/** * {@inheritDoc} */ @Override public void handle(IdentificationRequest request) throws IOException { final ZipFile zipFile = new ZipFile(new TrueZipReader(request.getWindowReader())); try { Iterable<ZipEntry> iterable = new Iterable<ZipEntry>() { @Override public final Iterator<ZipEntry> iterator() { return new ZipFileIterator(zipFile); } }; ZipArchiveWalker walker = new ZipArchiveWalker(request.getIdentifier(), zipFile); walker.walk(iterable); } finally { if (zipFile != null) { zipFile.close(); } } }